Results 1 to 2 of 2

Thread: selecting 2 diffrent sqls tables in the database

  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    23
    Thanks
    42
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Wink 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:
     
    $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."'"));
    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. #2
    Administrator GumSlone's Avatar
    Join Date
    Mar 2005
    Location
    Mars, GumCity
    Posts
    1,495
    Thanks
    125
    Thanked 572 Times in 201 Posts
    Blog Entries
    2
    Rep Power
    10

    Default

    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 [Only registered and activated users can see links. Click Here To Register...]

    [Only registered and activated users can see links. Click Here To Register...]


  3. The Following User Says Thank You to GumSlone For This Useful Post:

    hyperlad (09-10-10)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem with tables.
    By Malka1 in forum Site / Script testing and error fixing
    Replies: 7
    Last Post: 27-06-10, 17:55
  2. description selecting probz
    By Ponick in forum Site / Script testing and error fixing
    Replies: 4
    Last Post: 17-03-10, 11:03
  3. automatically optimize all the tables in your database
    By GiLL in forum Snippets, Functions and Classes
    Replies: 0
    Last Post: 14-01-10, 15:01
  4. selecting all emails from database and sending email
    By Dhruva7 in forum Coding Forum
    Replies: 13
    Last Post: 09-10-09, 15:57
  5. Database And Tables
    By CyberNet69 in forum Site / Script testing and error fixing
    Replies: 3
    Last Post: 23-02-09, 05:41

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19