I have been working with SQL queries for a while now but only recently has there been a need to introduce sub queries.
The following code works fine but I now need to be able to order the data by “table4.price” I have tried adding “ORDER BY table4.price” to the very end of the string and get an error informing me of an object required, so I tried adding it to the table4 sub query but there is not order to the results.
SELECT table1.*
FROM table1
WHERE table1.ID IN(SELECT ID FROM table2 WHERE allow=true)
AND table1.ID IN(SELECT ID FROM table3 WHERE catalogue=1)
AND table1.ID IN(SELECT ID FROM table4 WHERE price>0 AND price<500)
AND table1.ID NOT IN(SELECT ID FROM table5 WHERE date='01/11/2010')
<!-- ORDER BY table4.price -->
I built the string in this was so that the program can chop and change the string depending on how many search parameters are entered is there a way I can get this to work?
The following code works fine but I now need to be able to order the data by “table4.price” I have tried adding “ORDER BY table4.price” to the very end of the string and get an error informing me of an object required, so I tried adding it to the table4 sub query but there is not order to the results.
SELECT table1.*
FROM table1
WHERE table1.ID IN(SELECT ID FROM table2 WHERE allow=true)
AND table1.ID IN(SELECT ID FROM table3 WHERE catalogue=1)
AND table1.ID IN(SELECT ID FROM table4 WHERE price>0 AND price<500)
AND table1.ID NOT IN(SELECT ID FROM table5 WHERE date='01/11/2010')
<!-- ORDER BY table4.price -->
I built the string in this was so that the program can chop and change the string depending on how many search parameters are entered is there a way I can get this to work?