Reputation: 7175
I want to fetch value Rows from single table.I want to fetch sub_id for specific id.
I achieved my require ment in 2 query.I want to do it in single query.I want to display result 'Event,order history,Event Ticket,calander'.
$sql="select * from table1 where roles like %admin% and sub_id='0'"
$sql1=mysql_query($sql);
while($fet=mysql_fetch_assoc($sql1))
{
$id=$fet['id'];
$query="select page_name from table1 where sub_id= '$id'";
.. ..
}
Upvotes: 1
Views: 64
Reputation: 151
What you need are subqueries.
Basically, you would like to select some rows that match a criteria that is given by another query's result.
The example below should both resolve your issue and clarify the concept:
select
page_name
from
table1
where
sub_id in (
select
id
from
table1
where
roles like '%admin%'
and sub_id = 0
)
Upvotes: 1