Answer the question
In order to leave comments, you need to log in
Subscriber SQL query?
Tell me an approximate sql query for this construction:
There are Signatures for Users, Users have signatures for other Users .. you need to display all my Signatures + Signatures of Users for other Users
1.Col = User, 2.Col=
SubscriptionForUser 1
then the result is this:
2,3,4,3
If we choose for the User = 2
the
result is this
:
Массив_ИД_МоиПодписки = SELECT Юзер FROM ТаблицаПодписокЮзеров WHERE Юзер=%d
Массив_ИД_ПодпискиЮзеров = SELECT Юзер FROM ТаблицаПодписокЮзеров WHERE Юзер=Массив_ИД_МоиПодписки
ОбъединениеМассива(Массив_ИД_МоиПодписки,Массив_ИД_ПодпискиЮзеров)
SELECT t1.`ПодпискаНаЮзера`
FROM `ТаблицаПодписокЮзеров` t1
LEFT JOIN (
SELECT DISTINCT `ПодпискаНаЮзера` AS `parent`
FROM `ТаблицаПодписокЮзеров`
) AS t2 ON t1.`Юзер`= t2.`parent`
WHERE `Юзер`=%d
Answer the question
In order to leave comments, you need to log in
if you understand the problem correctly, then you can do without left join and other things, but just do
SELECT * FROM tablename WHERE col1 = 1 OR col1 IN (SELECT col2 FROM tablename WHERE col1 = 1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question