Results 1 to 3 of 3

Thread: Please show me best way to write this SQL statement

  1. #1

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Please show me best way to write this SQL statement

    Hi Guys,

    I want to write a query that selects a fieldname from a table where fieldname = a variable, so I would have:

    Code:
    SELECT OrgName froms Organisations WHERE Orgname = "+test+"

    Please show me the best way

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Please show me best way to write this SQL statement

    For such a simple query, there hardly is a better way. And writing a "better" SQL has many considerations that come way before how it is written per se.

    Such as what database is this? Each database has its own performance tuning tools and approaches. Which DML group are you prioritizing; selection vs insert/update/delete. Are there joins? What are the join conditions or join columns? Is there an index? Are you indexing the correct columns? Are the indexes too large or excessive, or is it the most appropriate index type? How large is the data? How fast does the data grow? Is this an OLTP with the tables normalized or a data warehouse where the data is denormalized? et, etc, etc.

    Each database has its own documentation regarding tuning... I suggest you start doing lots of research. Tuning is something you have to do yourself in coordination with your DBADM and can't be delegated to forums because its YOU who has access to and can view the database, it is YOU who can perform benchmarks, it is YOU who can weigh the pros and cons of each tuning decision (there may be performance penalties in other areas for gains in one area), it is YOU who can decide what needs to be changed at the database itself rather than forcing application level workarounds, etc etc.

    Again I stress this... this is something you can't easily delegate to forum members. We can only suggest rules of thumb but there are always exceptions to the rule.

  3. #3

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: Please show me best way to write this SQL statement

    thanks for the great advice leinad31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width