Hello,
I want to use left join to join 2 databases. I am trying to create a statement for hours for my php file but couldnt finish it =) ( maybe there is a better way than left join )
DB1 = tbllists / coloumns: (soru,onay,public,date,listid,publicid)
DB2 = tblcomments / columns: (oyid,listid,username,date,publicid)
What i want to do is get the list of "listid " of DB1: where onay=1 , public=1 and date is bigger or equal to today's date MINUS 15 days compared to rows of DB2 :
Check each row where listid we got from db1 is also exists in DB2, where username column is equal to username in app (will be taken by the app from a textfield via a php file , lets say it is $usn ) and remove those ids form the main listid list. ( shortly I want to get the listids of db1 where my user is not commented on that list id by checking db2, -if the user comments on one of the listid , the comment is added to db2-)
I am not sure how to do this in my php file and print it as json so i can retrieve them from my app. What i tried was
select * from tbllists left join tblcomments on tbllists.publicid=tblcomments.publicid where tbllists.public=1 and tbllists.tarih is bigger than today-15 ( dont know how to do it) and tbllists.onay=1
but could not add anything to compare with db2. I know it is complicated but any help would be perfect !
ty
I want to use left join to join 2 databases. I am trying to create a statement for hours for my php file but couldnt finish it =) ( maybe there is a better way than left join )
DB1 = tbllists / coloumns: (soru,onay,public,date,listid,publicid)
DB2 = tblcomments / columns: (oyid,listid,username,date,publicid)
What i want to do is get the list of "listid " of DB1: where onay=1 , public=1 and date is bigger or equal to today's date MINUS 15 days compared to rows of DB2 :
Check each row where listid we got from db1 is also exists in DB2, where username column is equal to username in app (will be taken by the app from a textfield via a php file , lets say it is $usn ) and remove those ids form the main listid list. ( shortly I want to get the listids of db1 where my user is not commented on that list id by checking db2, -if the user comments on one of the listid , the comment is added to db2-)
I am not sure how to do this in my php file and print it as json so i can retrieve them from my app. What i tried was
select * from tbllists left join tblcomments on tbllists.publicid=tblcomments.publicid where tbllists.public=1 and tbllists.tarih is bigger than today-15 ( dont know how to do it) and tbllists.onay=1
but could not add anything to compare with db2. I know it is complicated but any help would be perfect !
ty