AL123 Posted March 2, 2011 Share Posted March 2, 2011 I am new. I am trying to output a list of urls in a small app I am working on. Here is my first sql query that is printing the links: "SELECT categoryId FROM categories"; When you click on the link a second table is populated with the business information. SELECT * FROM business, businessCat WHERE businessCat.categoryId = '$catId' AND business.businessId = 'businessCat.categoryId' So when you click on the link the script calls itself, showing the business info. In trying to debug the problem in phpMyAdmin, I subsituted $catId for a value from the DB - 'Automotive'. No matter what, I return an empty set, here is the error: MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0005 sec ) any suggestions?? AL. Quote Link to comment https://forums.phpfreaks.com/topic/229421-empty-set/ Share on other sites More sharing options...
Maq Posted March 2, 2011 Share Posted March 2, 2011 I subsituted $catId for a value from the DB - 'Automotive'. No matter what, I return an empty set, here is the error: MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0005 sec ) That's not an error. If you're sure that 'Automotive' exists as a categoryId in the businessCat table, then your join is wrong. Quote Link to comment https://forums.phpfreaks.com/topic/229421-empty-set/#findComment-1182043 Share on other sites More sharing options...
AL123 Posted March 2, 2011 Author Share Posted March 2, 2011 Thanks I will give that a try. AL Quote Link to comment https://forums.phpfreaks.com/topic/229421-empty-set/#findComment-1182045 Share on other sites More sharing options...
AL123 Posted March 2, 2011 Author Share Posted March 2, 2011 Yes Automotive is there AL Quote Link to comment https://forums.phpfreaks.com/topic/229421-empty-set/#findComment-1182048 Share on other sites More sharing options...
DavidAM Posted March 2, 2011 Share Posted March 2, 2011 I suspect your query is not correct. SELECT * FROM business, businessCat WHERE businessCat.categoryId = '$catId' AND business.businessId = 'businessCat.categoryId' It looks like you are joining the categoryId (from businessCat) to the businessId (in business) (and what are those quotes doing in there?). Shouldn't that be something like this: SELECT * FROM business, businessCat WHERE businessCat.categoryId = '$catId' AND business.businessId = businessCat.businessId (changes in the last line) or, using the JOIN phrase: SELECT * FROM business JOIN businessCat ON business.businessId = businessCat.businessId WHERE businessCat.categoryId = '$catId' If categoryId is a number, then your page should be passing that number, not the name like "Automotive". I'm just guessing here since we don't have the table layouts, but I think this should help. If it doesn't, then post your table layouts (Table name, column names and datatypes) and possibly some sample data, so we can figure it out. Quote Link to comment https://forums.phpfreaks.com/topic/229421-empty-set/#findComment-1182055 Share on other sites More sharing options...
AL123 Posted March 2, 2011 Author Share Posted March 2, 2011 Thanks guys. I have to leave, but I will try to pick this up later this evening (with the table info). AL. Quote Link to comment https://forums.phpfreaks.com/topic/229421-empty-set/#findComment-1182073 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.