开发者

selecting certain column after a join operation

开发者 https://www.devze.com 2023-03-23 16:51 出处:网络
I have this sql: SELECT a.member_id, b.date, b.type, d.K_id, d.title, a.login FROM members as a JOIN permissions as b ON b.member_id = a.member_id

I have this sql:

  SELECT a.member_id, b.date, b.type, d.K_id, d.title, a.login
    FROM members as a
    JOIN permissions as b ON b.member_id = a.member_id
    JOIN titles as d ON d.k_id = b.k_id
   WHERE a.member_id = '$member'
ORDER BY b.date DESC

I want to select the login where type equals '3'. Can this be done without another select query?

I should rephrase based on the answers below .....I meant I wanted to select where type = 3 FROM t开发者_Go百科he results of this query.


SELECT a.member_id, b.date, b.type, d.K_id, d.title, a.login
FROM members as a
JOIN permissions as b
ON b.member_id = a.member_id
JOIN titles as d
ON d.k_id = b.k_id
WHERE a.member_id = '$member' and b.type = '3'
ORDER BY b.date DESC

or

WHERE a.member_id = '$member' and b.type = 3

depending on the type of type.


How about:

SELECT a.member_id, b.date, b.type, d.K_id, d.title, a.login
FROM members as a
JOIN permissions as b
ON b.member_id = a.member_id
JOIN titles as d
ON d.k_id = b.k_id
WHERE a.member_id = '$member' AND b.type = '3'
ORDER BY b.date DESC
0

精彩评论

暂无评论...
验证码 换一张
取 消