Skip navigation links

MySQL Forums :: PHP :: select and if statement


Advanced Search

select and if statement
Posted by: Hassan Ahmed ()
Date: March 09, 2013 03:46AM

al salam alikum =)


guys i want to know how to fix a complicated query


i have two tables
subsystem -> 1st table
topics -> 2nd table

subsystem :
subid
userid
type
typeid ;


topics :
topicid
title
catid
userid ;


and i got 3 records ( for example ) in the subsystem table like thie
1 - 1 - user - 1
2 - 1 - user - 2
3 - 1 - cat - 1


and i wanna to fetch the topics from topics table like this

query > select * from topics inner join subsystem on topics.userid=subsystem.userid where ( and here is the problem ! i want to fetch the topics where subsystem.typeid=userid "if subsystem.type=user" and where subsystem.typeid=catid "if subsystem.type=cat")

can anybody help !

and thnx =)

Options: ReplyQuote


Subject Written By Posted
select and if statement Hassan Ahmed 03/09/2013 03:46AM
Re: select and if statement Peter Brawley 03/09/2013 11:26AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.