473,513 Members | 2,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join query with foreign key

59 New Member
Hi,

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

SELECT first_name,last_name,user_email 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
Feb 2 '08 #1
2 1232
cvraghavan1979
28 New Member
Hi,

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

SELECT first_name,last_name,user_email 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
Feb 3 '08 #2
cvraghavan1979
28 New Member
Hi,

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

SELECT first_name,last_name,user_email 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
Feb 3 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2430
by: Marek Lewczuk | last post by:
Hello, I have a strange problem, maybe some of you will be able to explain me something. I use LEFT JOIN as a substitute for subselects. It's true that many subselects can be rewriten using LEFT...
1
3430
by: Paul Bramscher | last post by:
Here's one for pathological SQL programmers. I've got a table of things called elements. They're components, sort of like amino acids, which come together to form complex web pages -- as nodes...
6
2639
by: Rowan | last post by:
Hello, I am having a problem with a join. Either I am just not seeing the obvious, it isn't possible, or I need to use a different approach. I have an application with a vsflexgrid that needs...
1
1435
by: Justin | last post by:
Hello, I have a scenario where I have unique identifiers in about 25 tables, each table has varying fields - eg. Table #1 Table #2 Table #3 Table #4 --------- ...
6
2170
by: PW | last post by:
I've created an ASP application which uses an Access database. I've created an outer join query, but for some reason the "Property_Def" column is not aligning with the "ESPN" column. They should...
5
2723
by: Dot Net Daddy | last post by:
Hello, I have set up a database for movies. In one table (Movies) I have movie names, and production years, and also genres. In another table (Directors), I keep the directors and the movies...
1
2031
by: Simon Gare | last post by:
Hi all, having problem with query below SELECT DISTINCT dbo.logon.DRIVER_NO, dbo.booking_form.DriverNo FROM ((dbo.logon RIGHT JOIN dbo.Employees ON dbo.logon.DRIVER_NO =...
1
1933
by: teser3 | last post by:
I have 3 Access 2003 tables: TableMain MID PO TE INFO 1 2 3 ABC 2 2 1 EREER 3 1 3 OIUOI 4 3 3 PERE 5 2 2 DFE
1
1235
by: gubbachchi | last post by:
Hi, How to use foreign key with join queries. I have used the query SELECT first_name,last_name,user_email from Info,Registry WHERE user_id='1'; where user_id = foreign key ...
0
7257
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7379
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.