How do i write this as a join?

by 4 replies
5
I need to write this as a "JOIN", how do I do it?

("select * from c_projects where projects_id=$id AND active=1 AND item in (select item from cl_purchase where cemail='$_SESSION[member_username]' AND active > 0 AND item in permissions =$id)")

Thanks for your help!
#programming #join #write
  • I started writing something, but then realized I was probably not thinking of your DB right. Can you describe it a little?
    • [1] reply
    • This query runs just fine:
      ("select * from c_projects where projects_id=$id AND active=1 AND item in (select item from cl_purchase where cemail='$_SESSION[member_username]' AND active > 0 )")

      But I also need to make the association with the table permissions and column item:
      AND item in permissions =$id

      I have no clue how to write this out as a join query

      Thanks for the help
      • [1] reply
  • Your code is wide open to sql injection. Read this please: mysql - How to prevent SQL injection in PHP? - Stack Overflow

    Guess what would happen if I did this?

    Code:
     $ id = "'somevar'; DROP TABLE c_projects;";
    • [ 1 ] Thanks

Next Topics on Trending Feed

  • 5

    I need to write this as a "JOIN", how do I do it? ("select * from c_projects where projects_id=$id AND active=1 AND item in (select item from cl_purchase where cemail='$_SESSION[member_username]' AND active > 0 AND item in permissions =$id)")