Quantcast
Channel: MySQL Forums - PHP
Viewing all articles
Browse latest Browse all 938

select and if statement (1 reply)

$
0
0
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 =)

Viewing all articles
Browse latest Browse all 938

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>