Click here to Skip to main content
15,891,951 members
Home / Discussions / Database
   

Database

 
GeneralRe: How can I solve SQL EXPRESS 2005 problem in Visual Studio 2008? Pin
Blue_Boy17-Sep-08 23:39
Blue_Boy17-Sep-08 23:39 
GeneralRe: How can I solve SQL EXPRESS 2005 problem in Visual Studio 2008? Pin
JUNEYT18-Sep-08 0:11
JUNEYT18-Sep-08 0:11 
GeneralRe: How can I solve SQL EXPRESS 2005 problem in Visual Studio 2008? Pin
Blue_Boy18-Sep-08 0:14
Blue_Boy18-Sep-08 0:14 
Questionuse varchar(max) instead of varchar(50) Pin
Mogaambo17-Sep-08 22:40
Mogaambo17-Sep-08 22:40 
AnswerRe: use varchar(max) instead of varchar(50) Pin
Ashfield18-Sep-08 0:03
Ashfield18-Sep-08 0:03 
AnswerRe: use varchar(max) instead of varchar(50) Pin
nelsonpaixao18-Sep-08 13:32
nelsonpaixao18-Sep-08 13:32 
QuestionSQL Server 7.0 Pin
prubyholl17-Sep-08 21:07
professionalprubyholl17-Sep-08 21:07 
QuestionSelecting the top 1 item Pin
Christian Graus17-Sep-08 20:29
protectorChristian Graus17-Sep-08 20:29 
OK, so I have a table of businesses. Then I have a table of contacts. So, I have many contacts for the one business. I want to do a search, and use a contact name as a possible search. However, I don't ever want to return the same business more than once. So, I want to return each business that matches at least one contact, with any contact that matches. I've tried putting in a subquery so that I select the top 1 contact for a business, but I can't find a way to write SQL that works.

select
c.IDClient, c.Company, con.LastName + ', ' + con.FirstName as Contact, c.Phone, c.Fax
from tbl_client c
inner join tbl_client_contacts cc on cc.IDClient = c.IDClient
inner join tbl_contact con on con.IDContact = cc.IDContact
where con.IDContact = (select top 1 IDContact from tbl_client_contacts ccc where ccc.IDClient = c.IDClient)

Christian Graus

No longer a Microsoft MVP, but still happy to answer your questions.

AnswerRe: Selecting the top 1 item Pin
Blue_Boy17-Sep-08 21:33
Blue_Boy17-Sep-08 21:33 
GeneralRe: Selecting the top 1 item Pin
Christian Graus17-Sep-08 21:58
protectorChristian Graus17-Sep-08 21:58 
GeneralRe: Selecting the top 1 item Pin
Blue_Boy17-Sep-08 22:00
Blue_Boy17-Sep-08 22:00 
QuestionAn error occurs when an extra parameter is increased in application as well as stored procedure to the existing one Pin
sanjubaba17-Sep-08 20:20
sanjubaba17-Sep-08 20:20 
AnswerRe: An error occurs when an extra parameter is increased in application as well as stored procedure to the existing one Pin
Mycroft Holmes17-Sep-08 22:41
professionalMycroft Holmes17-Sep-08 22:41 
QuestionSSIS Packages Pin
geekfromindia17-Sep-08 13:42
geekfromindia17-Sep-08 13:42 
AnswerRe: SSIS Packages Pin
Mycroft Holmes18-Sep-08 2:47
professionalMycroft Holmes18-Sep-08 2:47 
GeneralRe: SSIS Packages Pin
geekfromindia19-Sep-08 5:18
geekfromindia19-Sep-08 5:18 
Questionsending sql info to (C#) application- advide needed Pin
nelsonpaixao17-Sep-08 13:24
nelsonpaixao17-Sep-08 13:24 
AnswerRe: sending sql info to (C#) application- advide needed Pin
Wendelius19-Sep-08 9:15
mentorWendelius19-Sep-08 9:15 
GeneralRe: sending sql info to (C#) application- advide needed Pin
nelsonpaixao21-Sep-08 15:47
nelsonpaixao21-Sep-08 15:47 
GeneralRe: sending sql info to (C#) application- advide needed Pin
Wendelius21-Sep-08 18:13
mentorWendelius21-Sep-08 18:13 
QuestionCreate recurring date in SQL statement Pin
Shane Leach17-Sep-08 11:34
Shane Leach17-Sep-08 11:34 
GeneralRe: Create recurring date in SQL statement Pin
nelsonpaixao17-Sep-08 12:04
nelsonpaixao17-Sep-08 12:04 
GeneralRe: Create recurring date in SQL statement Pin
Shane Leach18-Sep-08 3:29
Shane Leach18-Sep-08 3:29 
AnswerRe: Create recurring date in SQL statement Pin
RyanEK17-Sep-08 14:24
RyanEK17-Sep-08 14:24 
GeneralRe: Create recurring date in SQL statement Pin
Shane Leach18-Sep-08 3:27
Shane Leach18-Sep-08 3:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.