Skip to content
Advertisement

What is the difference between HAVING and WHERE in SQL?

What is the difference between HAVING and WHERE in an SQL SELECT statement? EDIT: I have marked Steven’s answer as the correct one as it contained the key bit of information on the link: When GROUP BY is not used, HAVING behaves like a WHERE clause The situation I had seen the WHERE in did not have GROUP BY and

How to “select until” a sum is reached

I’m looking for a way to select until a sum is reached. My “documents” table has “tag_id” and “size” fields. I want to select all of the documents with tag_id = 26 but I …

How to create relationships in MySQL

In class, we are all ‘studying’ databases, and everyone is using Access. Bored with this, I am trying to do what the rest of the class is doing, but with raw SQL commands with MySQL instead of using Access. I have managed to create databases and tables, but now how do I make a relationship between two tables? If I

Is RIGHT JOIN Ever Required?

Do any queries exist that require RIGHT JOIN, or can they always be re-written with LEFT JOIN? And more specifically, how do you re-write this one without the right join (and I guess implicitly …

coalesce alternative in Access SQL

In T-SQL, you can do this: SELECT ProductId, COALESCE(Price, 0) FROM Products How do you do the same thing in Access SQL? I see examples for doing it with Nz in VBA, but I’m looking for the SQL …

How do you OR two LIKE statements?

I have tried the following two statements: SELECT col FROM db.tbl WHERE col (LIKE ‘str1’ OR LIKE ‘str2’) AND col2 = num results in a syntax error SELECT col FROM db.tbl WHERE page LIKE (‘str1’ OR ‘…

Advertisement