Query Help!

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
njiang46
Forum Newbie
Posts: 1
Joined: Sun Apr 05, 2009 12:52 am

Query Help!

Post by njiang46 »

What I'm trying to do is to loop through the database for the possible results based on the previous results and stop until it reaches certain value. I put a simple query and hope that makes sens of what I'm doing here.

1st query - $item_B = SELECT * FROM listings WHERE listings.item_A LIKE '%anyfields%' - this is the query to return item_B
2nd query - $item_C = SELECT * FROM listings WHERE listings.listing_id = $item_B AND listings.item_name LIKE '%fields%' - this is the query to return item C
......keep going
Last query - SELECT * FROM listings WHERE listings.listing_id = $item_C AND listings.item_name LIKE '%fields%' - this is the query to return item Item_A. Once the Item_A matches the Item_A in the 1st query, the query should stop.

I'm not sure how to combine all this queries into one. Since there could be more e items involved in this query.

THANKS.
nyoka
Forum Commoner
Posts: 45
Joined: Thu Apr 09, 2009 12:53 pm

Re: Query Help!

Post by nyoka »

I will gladly help but would prefer to see the data in the database and what you want out, that way I may be able to suggest what queries to use, can you post some sample data and an explanation of which records (from the sample) you want returning?
Post Reply