I have this table:
With this query I'm extracting not activated songs, but I want to add a value (duplicate) if the song has an activated duplicate, how can I do it?
SELECT
libs.song_id,
songs.name AS song_name,
artists.id AS artist_id,
artists.name AS artist_name,
songs.description,
libs.status,
libs.activated,
libs.giftable,
IF(CONDITION, 1, 0) AS duplicate
FROM libs, songs, artists
WHERE
libs.song_id = songs.id &&
artists.id = songs.artist_id &&
libs.activated = 0 &&
libs.user_id = '1'
;
Thanks.
EDIT:
I expect to get this:
song_id|song_name|artist_id|artist_name|description|status|activated|giftable|duplicate
1 | "name" | "id" | "name" | "descr" | 0 | 0 | 1 | 1
2 | "name" | "id" | "name" | "descr" | 1 | 0 | 0 | 0