RE: [PHP-DB] how can i join this two selects
| From: | Rick Emery | Date: | Mon, 11 Mar 2002 22:07:41 +0000 |
| Subject: | RE: [PHP-DB] how can i join this two selects | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-17612@lists.php.net to get a copy of this message | ||
Vieliecht:
SELECT kat_id,immo_id FROM immo_kat WHERE immo_id=318 &&(kat_id = '1' OR
kat_id = '35' OR kat_id = '34') ORDER BY immo_id;
-----Original Message-----
From: Michael Plies [mailto:m.plies@raumfaktur.de]
Sent: Monday, March 11, 2002 4:01 PM
To: php-db@lists.php.net
Subject: [PHP-DB] how can i join this two selects
hy,
maybe im blind about this problem:
thats a row of my table(sql follows at the endof that mail) named
immo_kat
kat_id - immo_id - cr_uid - tstamp
------ ------- ------ ------
...
35 - 318 - 1 - 1015874898
34 - 318 - 1 - 0
...
now i like to get all immo_id's which have the same kat_id's like the
rows with the immo_id "318". With one query
means a join between two selects -
I.
SELECT kat_id
FROM immo_kat
where immo_id = 318
an with the result :
II.
SELECT immo_id
FROM immo_kat
where kat_id = '1' OR kat_id = '35' OR kat_id = '34'
Group by immo_id
I'm sorry - sound really easy - but maybe its to late
I would be very glad if someone can help me
heres the sql if needed
#
# Tabellenstruktur für Tabelle
immo_kat
#
CREATE TABLE immo_kat (
kat_id int(11) NOT NULL default '0',
immo_id int(11) NOT NULL default '0',
cr_uid int(11) NOT NULL default '0',
tstamp int(11) NOT NULL default '0',
KEY kat_id (kat_id)
) TYPE=MyISAM;
#
# Daten für Tabelle immo_kat
#
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(1,318,1,'');
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(1,277,1,'');
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(35,318,1,'');
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(34,277,1,'');
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(34,318,1,'');
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(36,315,1,1015874898);
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(34,315,1,1015874898);
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(1,299,1,1015876885);
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(34,311,1,1015876881);
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(36,313,1,1015876875);
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(34,327,1,1015875896);
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(1,289,1,1015876892);
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(34,289,1,1015876892);
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(36,289,1,1015876892);
INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES
(35,298,1,1015876904);
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php