Skip to content

Tag: sql

Select with joins in a unique table system

I am trying to build an SQL query on an omekaS database to extract books with a specific title and date. In this system, the table holding the values is called value, and the relevant attributes are as so : The resource_Id is the identifier through the db Value is one field; like the book “Moby Dick&#82…

Full Outer Join failing to return all records from both tables

I have a pair of tables I need to join, I want to return any record that’s in tableA, tableB or both. I think I need a FULL OUTER JOIN This query return 1164 records And this one return 3339 records And this one returns 3369 records (so there must be 30 records in tableA that aren’t in tableB) I

MySQL alternative way to `CASE` Statement

May I know, is there any alternative way or short way to write this case statement shown in the below: I tried using mysql built in funciton ifnull as below: ifnull(p.our_price,p.sales_price) But it doesn’t work for me. Answer You could stick with a CASE expression but use COALESCE to make it more succi…

Does the column order matter in a WHERE SQL statement

I’m working on a system with a good amount of indexes. Some indexes are simpler than others. I.e. they’re INT, VARCHAR, DATETIME and in some cases ENUMS(maybe 5~25 variations). Does the WHERE order matter? In other words, would placing the easier to search columns first increase speed/performance?…