On Wed, 2009-10-07 at 12:10 +0800, Kermit Mei wrote:
> Hello, I have three tables like this:
> 
> HomeDev(id,...,text)
> ZPhDev(id,...,HomeDevId)
> ZGroupItem(id,...,groupId,ZPhDevId)
> 
> Now, I want to get the items like this:
> 
> ZPhDev.id, and its corresponding HomeDev.text, the relation is like
> this:
> 
> 1. Get ZGroupItem.ZPhDevId When I know groupId
> 2. Get ZPhDev.HomeDevId When ZPhDev.id = ZGroupItem.ZPhDevId
> 3. Get HomeDev.text When ZPhDev.HomeDevId = HomeDev.id
> 
> How can I do it in only one sql command? I wrote it like this, but it
> can't run:
> sqlite> SELECT ZGroupItem.ZPhDevId HomeDev.text FROM ZGroupItem 
>    ...> INNER JOIN ZPhDev ON ZGroupItem.ZPhDevId = ZPhDev.id 
>    ...> WHERE ZGroupItem.groupId = 1;
> SQL error: near ".": syntax error

Now I had complished it:

sqlite> SELECT ZPhDev.id,HomeDev.text FROM HomeDev
   ...> INNER JOIN ZPhDev ON ZPhDev.HomeDevId = HomeDev.id
   ...> INNER JOIN ZGroupItem ON ZPhDev.id = ZGroupItem.ZPhDevId
   ...> WHERE ZGroupItem.groupId=1;


Thanks all the same;)

Kemrit Mei

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to