selecting 2 diffrent sqls tables in the database

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    selecting 2 diffrent sqls tables in the database

    Hi everyone hope your all good, I need help So i have a idea how to do it ,I have used search obviously before I posting this and looked on google but its not a detailed version of the idea I neeed , Right oh I want to select to two or more diffrent tables ok, for various codes Im using both Lavalair and wapdesire v2 but obviously in Lavalair birthday, top poster , shouter , member etc is in the users of the sqls part, but on the v2 of the script they are in profiles as you all no, Now I need to join them so I can select username from users and birthday etc from profiles I tried so many various ways its mad as its not having it, now the following code is actually from the v2 script
    Code:
     
    [SIZE=2]$birthday=mysql_fetch_array(mysql_query("SELECT b.birthday FROM users a INNER JOIN profiles b ON a.id=b.username WHERE a.id='".$username."'"));[/SIZE]
    But I cant seem get this working it should work because it calls the db for other stuff , as i said I dont just want it for birthday Im converting alot of stuff to try work for v2 so its not just the birthday code its for everything Im asking for help, Thanks for reading hope your Ideas can gimme bit insipration how to do it Thankyou Tony

    #2
    hmmmm,
    not sure if this will work better in your case, but you can try.
    PHP Code:
    $birthday=mysql_fetch_array(mysql_query("SELECT profiles.birthday FROM users LEFT JOIN profiles ON profiles.username=users.id WHERE users.id='".$username."'")); 
    but why you want to use join for this query if you select only one row, and profile and users have the same values "usernames" saved?

    this query will be enough.
    PHP Code:
    $birthday=mysql_fetch_array(mysql_query("SELECT profiles.birthday FROM profiles WHERE profiles.username='".$username."'")); 
    Advertise your mobile site for FREE with AdTwirl

    Comment

    Working...
    X