Click here to Skip to main content
15,892,927 members
Home / Discussions / Database
   

Database

 
GeneralRe: connection string Pin
LiYS4-Nov-08 20:18
LiYS4-Nov-08 20:18 
GeneralRe: connection string Pin
Giorgi Dalakishvili4-Nov-08 20:25
mentorGiorgi Dalakishvili4-Nov-08 20:25 
Questionget difference between two double precision columns Pin
kani984-Nov-08 12:36
kani984-Nov-08 12:36 
AnswerRe: get difference between two double precision columns Pin
Blue_Boy4-Nov-08 14:26
Blue_Boy4-Nov-08 14:26 
GeneralRe: get difference between two double precision columns Pin
kani984-Nov-08 17:52
kani984-Nov-08 17:52 
AnswerRe: get difference between two double precision columns Pin
Wendelius4-Nov-08 18:13
mentorWendelius4-Nov-08 18:13 
Questioncorrelated subselect Pin
Smithers-Jones4-Nov-08 0:30
Smithers-Jones4-Nov-08 0:30 
AnswerRe: correlated subselect [modified] Pin
Wendelius4-Nov-08 4:58
mentorWendelius4-Nov-08 4:58 
First I have to say that I haven't used MySQL so I'm guessing here.

Typically table aliases do not use AS keyword so perhaps the statement should be:
SELECT * FROM myTable T1 WHERE ColDate=(SELECT MAX(T2.ColDate) FROM myTable T2 WHERE T1.NameID=T2.NameID)

Also there may be problems if there are two records with the same date since then your subquery will return two rows and that's not acceptable when using = operator. If this happens, use for example both MAX(ColDate) and MIN(ColID) (or something similar) to get only one row from subwuery.

edit: Another option could be using GROUP BY ... HAVING ... clauses

Hope this helps,


Mika

The need to optimize rises from a bad design.

My articles[^]

modified on Tuesday, November 4, 2008 12:19 PM

GeneralRe: correlated subselect Pin
Smithers-Jones4-Nov-08 8:07
Smithers-Jones4-Nov-08 8:07 
GeneralRe: correlated subselect Pin
Wendelius4-Nov-08 8:23
mentorWendelius4-Nov-08 8:23 
AnswerRe: correlated subselect Pin
Blue_Boy4-Nov-08 6:10
Blue_Boy4-Nov-08 6:10 
GeneralRe: correlated subselect Pin
Smithers-Jones4-Nov-08 9:24
Smithers-Jones4-Nov-08 9:24 
AnswerRe: correlated subselect Pin
SomeGuyThatIsMe4-Nov-08 7:28
SomeGuyThatIsMe4-Nov-08 7:28 
GeneralRe: correlated subselect Pin
Smithers-Jones4-Nov-08 8:25
Smithers-Jones4-Nov-08 8:25 
GeneralRe: correlated subselect Pin
SomeGuyThatIsMe4-Nov-08 8:31
SomeGuyThatIsMe4-Nov-08 8:31 
GeneralRe: correlated subselect Pin
Smithers-Jones4-Nov-08 8:52
Smithers-Jones4-Nov-08 8:52 
GeneralRe: correlated subselect Pin
SomeGuyThatIsMe4-Nov-08 9:39
SomeGuyThatIsMe4-Nov-08 9:39 
GeneralRe: correlated subselect Pin
Smithers-Jones5-Nov-08 0:43
Smithers-Jones5-Nov-08 0:43 
JokeRe: correlated subselect Pin
Smithers-Jones5-Nov-08 0:37
Smithers-Jones5-Nov-08 0:37 
GeneralRe: correlated subselect Pin
PIEBALDconsult5-Nov-08 14:39
mvePIEBALDconsult5-Nov-08 14:39 
QuestionOpinion on how to handle a DataSet Pin
stormydaniels4-Nov-08 0:05
stormydaniels4-Nov-08 0:05 
AnswerRe: Opinion on how to handle a DataSet Pin
Wendelius4-Nov-08 4:53
mentorWendelius4-Nov-08 4:53 
QuestionConfigure Auto Database Replication Problem Using Sql Server 2000 Pin
veereshIndia3-Nov-08 18:55
veereshIndia3-Nov-08 18:55 
AnswerRe: Configure Auto Database Replication Problem Using Sql Server 2000 Pin
Wendelius4-Nov-08 5:05
mentorWendelius4-Nov-08 5:05 
QuestionDebugging a stored procedure Pin
dptalt3-Nov-08 10:29
dptalt3-Nov-08 10:29 

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.