Hi there, I am a newbie to MSSQL. I apologise first as I know that my question might have been asked by others elsewhere but unfortunately I couldn't find it. I will really appreciate if someone can shed some light into my question.

I have two tables with the following fields respectively:

1. ProjectTABLE
projectid (int)
projectName (varchar)

2. photoTABLE
photoid (int)
projectid (int)
path (varchar)
approved (true or false)

I would like to retrieve the projectid, projectName, (path, where photoTABLE.approved=true), where projectid = @projectid

How can this be possibly done. How the SQL query should be written? Thanks.

Recommended Answers

All 3 Replies

Hi you can use the following query.
declare approved as 'varchar'

select projectid,projectname,path from projecttable, phototable where projecttable.projectid= phototable.projectid and phototable.appoved like 'true'

Let me know if you face any problem with this query.

Hi there, thanks for the response. It solves my problem. I just realised from your post that what I need is the AND parameter :)

thanks its really very helpfull in my final year project

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.