Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

SQL query question

  • 09-03-2003 1:22pm
    #1
    Closed Accounts Posts: 539 ✭✭✭


    It's ok I found the answer, delete if you please.


Comments

  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    I was just about to answer too :rolleyes: ;)


  • Closed Accounts Posts: 7,563 ✭✭✭leeroybrown


    It would have been nice if you left the question up and posted the solution you found. That way everyone benefits ...


  • Closed Accounts Posts: 539 ✭✭✭Yurmasyurda


    Too lazy to re-write the question but the gist was how to combine a query command in one statement, it was a bit complicated but roughly what I was doing was...


    select * from SMSSend where senddate='1900-01-01'
    select * from SMSSend where SMSTo='NULL'
    select * from SMSSend where SMSSender='New'


    what I should've done was...

    select * from SMSSend where senddate='1900-01-01'
    and SMSTo <> 'NULL'
    and SMSSender <> 'New'

    :)


  • Business & Finance Moderators, Entertainment Moderators Posts: 32,387 Mod ✭✭✭✭DeVore


    That is a better way alright but occasionally you DO need to stitch together two similar recordsets.

    select field1, field2 from <tablename> where <criteria>
    UNION
    select field1a, field2a from <table2name> where <criteria2>

    Now so long as field1 and field2 are similar to field1a and field2a and there is the same number of coumns in both recordsets then you can use the UNION command to make one big recordset out of them.

    I think there may even be relaxations recently about the amount the two recordsets have to match but thats an RDBMS-specific problem.

    DeV.


  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    Certainly selecting * is bad. Select specific fields, this is faster.

    Much like using inline sql where you can instead of using cursors.

    bump.


  • Advertisement
Advertisement