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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.