Skip to content

Tag: mysql

Query BETWEEN TWO TABLES OUTPUT (MYSQL)

two table EMPLOYEE and Department EMPLOYEE’s fields are ID,Name, Salary ,DEPT_ID(foreign key to department table) DEPARTMENT’S fields are id,NAME,LOCATION VALUES OF EMPLOYEE TABLE WILL Be Values OF DEPARTMENT TABLE WILL BE Output from these table should be DEPARTMENT_Name should be alpabetically w…

Summing condition excludes rows without positive sum

I’m having a weird issue where in returning the sum of rows where a condition is true seems to only return rows if that condition is true – or at least, it is excluding a large majority of the rows that would otherwise be returned. Original query – which returns all rows: For each row that w…

MySQL ORDER BY FIELD for months

I have a table called months – this contains all 12 months of the calendar, the IDs correspond to the month number. I will be running a query to retrieve 2 or 3 sequential months from this table, e.g April & May June, July, August December & January However I want to ensure that whenever Decembe…

JOIN query and ANY query produced different results

I am new to SQL and I can’t figure out why the following two queries would have different results. The purpose is to list product names if there are any records in the order details table that quantity = 10. The first statement gives more results than the second one. I am using the “Northwind samp…