PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am trying to select data from another table using UNION ALL SELECT but I seem to be getting continuous errors saying, You have an error in your SQL syntax near 'UNION ALL SELECT products FROM shopping_cart' at line 1. This is my code:
mysql manual wrote:(SELECT a FROM tbl_name WHERE a=10 AND B=1 ORDER BY a LIMIT 10)
UNION
(SELECT a FROM tbl_name WHERE a=11 AND B=2 ORDER BY a LIMIT 10)
ORDER BY a;
UNION is only available as of MySQL 4.x and above - which is always worth checking (my host still uses 3.x for example) - also in your given example I can't even see the need for a union anyway as you only seem to be bringing back one table - but that might just be the way you wrote it. If all you want to do is bring back everything from 2 un-related tables (that cannot be joined) it's just: