Jump to content

running multiple queries


searls03

Recommended Posts

hi there.  i am trying to run a query that will select values from two tables.  I would like to run a query to select an event name and an id from table1, and then select subevent from table2 where the event_id is equal to the id from table1 query.  i know how to do this via a couple of loops, but I only want one loop.  can anyone help me get started?  thanks

Link to comment
https://forums.phpfreaks.com/topic/275422-running-multiple-queries/
Share on other sites

It has nothing to do with loops. This can be achieved in a single query.


SELECT a.something, b.somethingelse
FROM table_a a
LEFT JOIN table_b b USING(table_a_id)
If you need more help take a look at some tutorials on using a "MySql JOIN" or post your table structure so we can give you a more concrete example.

 

It has nothing to do with loops. This can be achieved in a single query.

SELECT a.something, b.somethingelse
FROM table_a a
LEFT JOIN table_b b USING(table_a_id)
If you need more help take a look at some tutorials on using a "MySql JOIN" or post your table structure so we can give you a more concrete example.

You want to run ONE query. Not two queries. Not multiple queries in loops. One Query.

 

 

SELECT card.event_id, card.qty, card.event,
       events.spots, events.name
FROM card
JOIN events
  ON events.id = card.event_id

 

Did I mention that you only need to run ONE query?

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.