Excel Posted June 24, 2009 Share Posted June 24, 2009 hi! I want to write an sql syntax. I have products table: id, name, in_category. I have categories table: id, name. i need to select: All products that there category name is deferent from the text 'free'. Can someone show me how to write this? tnx ! Quote Link to comment https://forums.phpfreaks.com/topic/163483-solved-how-to-write-this-sql-syntax/ Share on other sites More sharing options...
Zane Posted June 24, 2009 Share Posted June 24, 2009 SELECT *.a FROM products a INNER JOIN categories b ON a.in_category = b.id WHERE b.name NOT LIKE '%free%' Quote Link to comment https://forums.phpfreaks.com/topic/163483-solved-how-to-write-this-sql-syntax/#findComment-862566 Share on other sites More sharing options...
Excel Posted June 24, 2009 Author Share Posted June 24, 2009 hi. tnx. my sql query: SELECT *.a FROM virtual_store_products a INNER JOIN virtual_store_categories b ON a.category_id = b.id WHERE b.title NOT LIKE '%free%' error: SQL/DB Error -- [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.a FROM virtual_store_products a INNER JOIN virtual_store_categories b ON a.cate' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/163483-solved-how-to-write-this-sql-syntax/#findComment-862573 Share on other sites More sharing options...
Excel Posted June 24, 2009 Author Share Posted June 24, 2009 ok... the good code is: SELECT * FROM products a INNER JOIN categories b ON a.in_category = b.id WHERE b.name NOT LIKE '%free%' 10x ! Quote Link to comment https://forums.phpfreaks.com/topic/163483-solved-how-to-write-this-sql-syntax/#findComment-862586 Share on other sites More sharing options...
Zane Posted June 24, 2009 Share Posted June 24, 2009 My bad, I meant for it to be SELECT a.* FROM products a INNER JOIN categories b ON a.in_category = b.id WHERE b.name NOT LIKE '%free%' notice the a.* that way you don't get all the columns from categories too. Quote Link to comment https://forums.phpfreaks.com/topic/163483-solved-how-to-write-this-sql-syntax/#findComment-862797 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.