SELECT * FROM Customers WHERE CustomerID < 10000
ORDERBY Country ASC, CustomerName DESC;
Is it a valid way to have WHERE and ORDER BY in the same line of code?
Thanks.
SELECT * FROM Customers WHERE CustomerID < 10000
ORDERBY Country ASC, CustomerName DESC;
Is it a valid way to have WHERE and ORDER BY in the same line of code?
Thanks.
Need a space between Order BY
See this for info
Here is a sample from one of my test queries.
Code:SELECT tblEquipInOut.TransactionId , tblEquipInOut.TransactionDate , tblEquipInOut.CrewChiefName , tblEquipInOut.EquipOutIn , tblEquipInOut.BarCode FROM tblEquipInOut WHERE (((tblEquipInOut.EquipOutIn)="IN")) ORDER BY tblEquipInOut.TransactionDate;
Thanks. That was just a typo.Need a space between Order BY
See this for info
Just out of curiosity, why don't you just try it?Is it a valid way to have WHERE and ORDER BY in the same line of code?
The answer is it depends. In a query you can write
SELECT * FROM Customers WHERE CustomerID < 10000 ORDER BY Country ASC, CustomerName DESC;
or pretty much any combination - words need to be separated by one or more spaces or a return
would also workCode:SELECT * FROM Customers WHERE CustomerID < 10000 ORDER BY Country ASC , CustomerName DESC
Normal convention is to break it up into the different sections
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
but if writing the query in vba, you are creating a string - so you need to make sure you have spaces between words - or I guess use vbcrlf - though I have never tried it that way.