Jump to content

Empty set


AL123

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/229421-empty-set/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/229421-empty-set/#findComment-1182043
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/229421-empty-set/#findComment-1182055
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.