mysql - Sql statement return with zero result -
i trying choose row where
1)list.ispublic = 1
2)userlist.userid='aaa'
, userlist.listid=list.listid
i need 1)+2)
there row statement can not row, there problem?
list table:
listid listname creator isremindsub isremindunsub ispublic createdate lastmodified reminder 1 test2 aaa 0 0 1 2012-03-09 null null
user_list table (no row):
userid listid userrights
my test version
select * list l inner join user_list ul on ul.listid = l.listid l.ispublic = 1 , ul.userid = '09185346d'
this result when there 2 list in user_list has aaa , , 1 list public in list, cause double retrieve of 1 public list in list if in php ?
listid listname creator isremindsub isremindunsub ispublic createdate lastmodified reminder userid listid userrights 1 test2 aaa 0 0 1 2012-03-09 null aaa 1 read 2 t2 aaa 0 0 1 2012-03-09 null aaa 2 read
first, try select
fields need. second, write joins
explicitly - helps readability. example:
select l.*, ul.* list l inner join user_list ul on ul.listid = l.listid l.ispublic = 1 , ul.userid = 'aaa'
incidentally, if have no data in user_list
table, have no way meet requirements have set. if put "userlist.listid=list.listid" necessary , user_list
table empty, 0 rows returned.
edit: , no, won't cause rows retrieved double. whatever results sql query same results in php script - mechanism retrieving data same.
Comments
Post a Comment