asmith Posted December 20, 2007 Share Posted December 20, 2007 can i search a column to see if at least 2 values are the same in 2 different rows ? i need to choose one value from a table IF no other row has the same values . example : table : id int1 int2 int3 int4 1 56 24 36 48 2 14 34 23 29 3 56 24 34 44 4 34 26 76 23 i want to select id , where int1 is the max . if it found 2 or more rows with the same max number, then select id from this 2 or more where int2 is the max , if int2 were the same .... goto int3 ..... int 4 . if the last int were the same too , select nothing . can i do that ? Quote Link to comment Share on other sites More sharing options...
asmith Posted December 20, 2007 Author Share Posted December 20, 2007 ok , if that is not possible , how can i search it a row where a column is max in it ? i searched for an hour but didn't find what i want . something like : select id from table where int1 is maximum it seems i can't get a right syntax for it , how can i achieve this ? Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted December 20, 2007 Share Posted December 20, 2007 Select id, MAX(int1) FROM table_name; download mysql reference manual from here http://dev.mysql.com/doc/ it is free Quote Link to comment Share on other sites More sharing options...
asmith Posted December 20, 2007 Author Share Posted December 20, 2007 well that is not working ! it says it needs group ! Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted December 20, 2007 Share Posted December 20, 2007 Weeeeelll.....I thought you were going to download that reference manual and see some examples Select id, MAX(int1) FROM table_name GROUP BY id; But better you download that manual and start studying so you don't have to wait for simple questions ... Quote Link to comment Share on other sites More sharing options...
asmith Posted December 20, 2007 Author Share Posted December 20, 2007 you're right , i'm so sorry about it . my internet speed is something like dialup 56k . and it take so long. i know i'm giving stupid excuses ,i've start downloading the pdf file. thanks for your answer and your patience ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.