Join query with foreign key

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gubbachchi
    New Member
    • Jan 2008
    • 59

    Join query with foreign key

    Hi,

    How to use foreign key with join queries. I have used the query

    SELECT first_name,last _name,user_emai l from Info,Registry WHERE user_id='1';

    where user_id = foreign key
    first_name,last _name are in table Info
    user_email in table Registry
    user_id is a foreign key which references the parent key present in seperate database.
    . The query is returning empty set even though there are results in mysql table.

    What is the reason for this. Can anyone help me.

    Thanks
    Last edited by gubbachchi; Feb 2 '08, 08:00 AM. Reason: make it clear
  • cvraghavan1979
    New Member
    • Jan 2008
    • 28

    #2
    join query with foreign key

    Originally posted by gubbachchi
    Hi,

    How to use foreign key with join queries. I have used the query

    SELECT first_name,last _name,user_emai l from Info,Registry WHERE user_id='1';

    where user_id = foreign key
    first_name,last _name are in table Info
    user_email in table Registry
    user_id is a foreign key which references the parent key present in seperate database.
    . The query is returning empty set even though there are results in mysql table.

    What is the reason for this. Can anyone help me.

    Thanks
    Hi,

    u've written that the user_id is in a separate database, then how u r linking the tables info and registry. to perform a join there should b atleast one column in common, but u'ven't used to common column in query. may b that's the pbm.

    regards,
    vijay
    Last edited by cvraghavan1979; Feb 3 '08, 11:23 AM. Reason: spelling

    Comment

    • cvraghavan1979
      New Member
      • Jan 2008
      • 28

      #3
      Originally posted by gubbachchi
      Hi,

      How to use foreign key with join queries. I have used the query

      SELECT first_name,last _name,user_emai l from Info,Registry WHERE user_id='1';

      where user_id = foreign key
      first_name,last _name are in table Info
      user_email in table Registry
      user_id is a foreign key which references the parent key present in seperate database.
      . The query is returning empty set even though there are results in mysql table.

      What is the reason for this. Can anyone help me.

      Thanks
      Hi,

      u've written that the user_id is in a separate database, then how u r linking the tables info and registry. to perform a join there should b atleast one column in common, but u'ven't used to common column in query. may b that's the pbm.

      regards,
      vijay

      Comment

      Working...