List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:March 12 2006 4:31pm
Subject:Re: Query help
View as plain text  
OKAN ARI wrote:
> I have 3 tables
> Table 1: user(id, name, surname)
> Table 2: crime(id, detail)
> Table 3: user_crime(id, user_id, crime_id)
>
> Table 1
> 1, OKAN, ARI
>
> Table 2
> 1, "detail 1"
> 2, "Detail 2"
>
> Table 3
> 1, 1, 1
> 1, 1, 2
>
> So user 1 takes 2 crime from crime table...
>
> I want to receive info with 1 query: I need name surname and his 
> crime_ids of user_id 1
> So result might be:
> user_id, name, suername, crime_ids
> 1, OKAN, ARI, {1-2}
SELECT u.name, u.surname, uc.crime_id, c.detail
FROM user AS u
INNER JOIN user_crime AS uc ON u.id=uc.user_id
INNER JOIN crime AS c ON uc.crime_id=c.id
WHERE u.id=1

PB
>
>
> Is it possible?
>
> gibi....
>
> Mumkun mu?
>
>
> -----------------------------------------------------
> Iletisim teknolojilerinin gucunu ispatlayan iletisim teknolojileri 
> dergisi: Tele.com.tr
> http://www.tele.com.tr
>


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.2.1/279 - Release Date: 3/10/2006

Thread
best method to backup this mysql dataNeil Tompkins11 Mar
  • Re: best method to backup this mysql dataMladen Adamovic11 Mar
    • Re: best method to backup this mysql dataNeil Tompkins11 Mar
  • RE: best method to backup this mysql dataNicolas Verhaeghe11 Mar
    • Query helpOKAN ARI12 Mar
      • Re: Query helpPeter Brawley12 Mar