I am trying to compare two sets of attempts with great difficulty to undesrtand how subqueries work and if they are effective. I am not going to explain all my tables, but just think that I have apar arrays ... I can do this in php, but I wonder if I can do this in mysql right away ...
this is my request to check how many items user 1 has in his lists
SELECT DISTINCT *
FROM list_tb
INNER JOIN item_to_list_tb
ON list_tb.list_id = item_to_list_tb.list_id
WHERE list_tb.user_id = 1
ORDER BY item_to_list_tb.item_id DESC
this is my request to check how many items user 2 has in his lists
SELECT DISTINCT *
FROM list_tb
INNER JOIN item_to_list_tb
ON list_tb.list_id = item_to_list_tb.list_id
WHERE list_tb.user_id = 1
ORDER BY item_to_list_tb.item_id DESC
now the problem is that I would cross these results to check how many item_id elements they have in common ...
thank!!!
source
share