Why is the `LIKE` operator not working with integer columns?
I’m trying to receive some ids from my database for an autocomplete search on my CAKEPHP 3.3 site. But my problem is that its only returning the id if I type in the exact id and not part of it. Here...
View ArticleYii2 How to translate SUM SQL function to Query Builder?
I have this simple SQL query: SELECT product_name, SUM (product_amount) FROM orders GROUP BY product_name; It will show a list with product names and their amounts. Like this example: I want to...
View ArticleIs it possible to translate this “join” and “as” query to Laravel PDO functions?
I am struggling to make this SQL query to a Laravel PDO query. Does anyone know how I can do this? (Especially the 'AS' statements and the naming in the joins). Query: SELECT models.name as...
View ArticleTypeOrm: Selecting results that contain all values in array
I am having some trouble getting the data I want from a Typeorm query. Basically, we have a search bar for the users to search our database of products (medicines). I want to select all records from...
View ArticleConvert Raw SQL to Bookshelf/Knex
I’m trying to convert a simple raw SQL to use Bookshelf/Knex in JavaScript: Original SQL: select * from o where o.id = 1 or o.id = 2 and (o.is_a = true or o.is_b = true) and o.status = 'good'; I’ve...
View ArticleHow do I convert SQL statement with alias in a valid Laravel query builder?
I am working on a Laravel 8 application. I have the flowing SQL statement containing the alias country for the column name of the countries table: SELECT users.first_name, users.last_name,...
View ArticleLaravel 9 query builder where clause has empty model id
I’m working on a Laravel 9 project and have created a custom validation rule called ValidModelOwnership which should check that the field a user is trying to add is owned by a model based on some...
View Article
More Pages to Explore .....