Click here to Skip to main content
15,914,162 members
Home / Discussions / Database
   

Database

 
QuestionHow do you do with .mdb? Pin
Anonymous5-Feb-05 1:32
Anonymous5-Feb-05 1:32 
AnswerRe: How do you do with .mdb? Pin
Yulianto.6-Feb-05 18:11
Yulianto.6-Feb-05 18:11 
QuestionASP .NET, MS SQL Server 2000 with Window XP SP2 <- does not work??? Pin
Thang T.4-Feb-05 22:46
Thang T.4-Feb-05 22:46 
AnswerRe: ASP .NET, MS SQL Server 2000 with Window XP SP2 <- does not work??? Pin
Hesham Amin4-Feb-05 23:05
Hesham Amin4-Feb-05 23:05 
GeneralRe: ASP .NET, MS SQL Server 2000 with Window XP SP2 <- does not work??? Pin
Thang T.5-Feb-05 0:32
Thang T.5-Feb-05 0:32 
GeneralSQL Server fills event log Pin
Hesham Amin4-Feb-05 20:00
Hesham Amin4-Feb-05 20:00 
GeneralRe: SQL Server fills event log Pin
Hesham Amin4-Feb-05 23:48
Hesham Amin4-Feb-05 23:48 
GeneralDifficult JOIN Pin
Luis Alonso Ramos4-Feb-05 15:24
Luis Alonso Ramos4-Feb-05 15:24 
Hello,

Here's a good question for all you SQL gurus here in CP.

I have a Customers table with PK ID_customer and other customer information such as name, birth date, etc.

I have an Addresses table which contains all the information for an address, such as street, exterior number and so on. The primary key is ID_address, and contains ID_customer field for relating it to the customer. This table contains a foreign key ID_city. Each address has a date indicating since when it is valid (one starting 1/1/2000 and another from 1/1/2001 for example.)

My Cities table contains a PK ID_city for each of the cities that are allowed in an address, and another field CityName.

So, I developed a stored procedure to find all the records matching certain criteria (all fields in the Customer table) using IF NOT @param = NULL to check the different criteria (I can search by name or by customer ID, for example) and performing a SELECT query.

My problem is that this SELECT query must return only one record for each customer matching, and that record must contain the CityName for the latest address for that customer (or blank if no address registerd). I can do the JOIN, and with a GROUP BY but it returns one record for each different city each customer has.

So, any ideas?

-- LuisR



Luis Alonso Ramos
Intelectix - Chihuahua, Mexico

Not much here: My CP Blog!

GeneralRe: Difficult JOIN Pin
Yulianto.4-Feb-05 16:05
Yulianto.4-Feb-05 16:05 
GeneralRe: Difficult JOIN Pin
Luis Alonso Ramos4-Feb-05 19:18
Luis Alonso Ramos4-Feb-05 19:18 
GeneralRe: Difficult JOIN Pin
Mike Dimmick5-Feb-05 1:52
Mike Dimmick5-Feb-05 1:52 
GeneralRe: Difficult JOIN Pin
Luis Alonso Ramos5-Feb-05 6:41
Luis Alonso Ramos5-Feb-05 6:41 
GeneralRe: Difficult JOIN Pin
Mike Dimmick5-Feb-05 7:32
Mike Dimmick5-Feb-05 7:32 
GeneralRe: Difficult JOIN Pin
Luis Alonso Ramos5-Feb-05 8:13
Luis Alonso Ramos5-Feb-05 8:13 
Generali can't to insert a new row Pin
Sasuko4-Feb-05 6:38
Sasuko4-Feb-05 6:38 
GeneralRe: i can't to insert a new row Pin
tojamismis4-Feb-05 6:52
tojamismis4-Feb-05 6:52 
GeneralRe: i can't to insert a new row Pin
Sasuko4-Feb-05 11:00
Sasuko4-Feb-05 11:00 
GeneralRe: i can't to insert a new row Pin
tojamismis4-Feb-05 11:23
tojamismis4-Feb-05 11:23 
GeneralRe: i can't to insert a new row Pin
Sasuko4-Feb-05 11:30
Sasuko4-Feb-05 11:30 
GeneralRe: i can't to insert a new row Pin
tojamismis4-Feb-05 14:11
tojamismis4-Feb-05 14:11 
GeneralRe: i can't to insert a new row Pin
Sasuko4-Feb-05 22:29
Sasuko4-Feb-05 22:29 
GeneralRe: i can't to insert a new row Pin
Sasuko4-Feb-05 23:58
Sasuko4-Feb-05 23:58 
GeneralRe: i can't to insert a new row Pin
tojamismis5-Feb-05 4:49
tojamismis5-Feb-05 4:49 
GeneralRe: i can't to insert a new row Pin
Sasuko5-Feb-05 12:22
Sasuko5-Feb-05 12:22 
GeneralRe: i can't to insert a new row Pin
tojamismis5-Feb-05 4:47
tojamismis5-Feb-05 4:47 

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.