I’m having some trouble and can’t seem to find the solution. Hopefully someone here can help me out.

I have two tables in a SQL Database and I’m trying to select some information from both tables where the column‘UniqueID’ has the same value.


Here is the information I require from the Tables:

Table Name:
Featured

Column Names:
UniqueID (value for both tables)
Approve
Date_Activation

Table Name:
Information

Column Names:
UniqueID (value for both tables)
Headline
Description
Ref_No
Rowguid

I found some information that said I could create a WHERE statement like the following:

where Table1.ColumnName = Table2.ColumnmName

I have tried this and it’s not working. Here’s my code:

select 
UniqueID as UniqueID,
Headline as Headline,
Description as Description, 

case when Approve = '1' then 'True' when Approve is null then 'False' else 'False' end as Approve,
Ref_No as RefNo,
Rowguid

from Featured, Information
Where Featured.UniqueID = Information.UniqueID
order by Date_Activation asc

Any help with this would be greatly appreciated.

Recommended Answers

All 3 Replies

Try this one:

select
a.UniqueID,a.Headline,a.Description,b.Date_Activation,
case when b.Approve = '1' then 'True' when b.Approve is null then 'False' else 'False' end as Approve,
a.Ref_No as RefNo,
a.Rowguid

from Featured b inner join Information a
on a.UniqueID = b.UniqueID
order by b.Date_Activation asc

Thanks sufyan,

that's working greate!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.