• TheSQLGuru (6/10/2014)


    ramana3327 (6/10/2014)


    Hi All,

    I do have table Ex: customer. I do have some select statements based in where clause studentid.

    I am retrieving

    student name, age , marital status, contact no from student where student id=1

    student name, age , marital status, contact no from student where student id=2

    student name, age , marital status, contact no from student where student id=3

    I tried in the following way

    select student name, age , marital status, contact no from student where student id in (1,2,3)

    and I tried

    student name, age , marital status, contact no from student where student id=1 or student id=2 or student id=3

    but the total no of records are varying. Is there any way to optimize those queries

    Thanks,

    1) I am having a hard time seeing that those queries returned something other than the same 3 rows (assuming you have records with IDs of 1, 2 and 3).

    2) What makes you think those queries are not optimized already? What metric did you use to say they were not returned as fast or as efficient as they could be?

    I'm with Kevin on this one. There must be something else to it that I'm not seeing if those queries return different data. Could you please post the DDL for the table and the SQL queries you actually ran?