SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Location
    Kew Gardens, United States
    Posts
    2,596
    Post Thanks / Like
    Blog Entries
    1
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0

    SQL IF...Then....Else

    I am converting English sentences into SQL.

    How do I handle branches?

    Select something from myTable
    If something is equal to 'Cat' then do SQL A , otherwise do SQL B.

    Is this where Selects inside of selects come into play? Is there another way to do this?

    Thanks,

    Kevin
    When in Florida, Don't Tampa with the code. I made this up.

  2. #2
    SQA Knight
    Join Date
    May 2006
    Location
    Playa Del Rey, California, United States
    Posts
    2,594
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0
    Quote Originally Posted by bklabel1 View Post
    I am converting English sentences into SQL.

    How do I handle branches?

    Select something from myTable
    If something is equal to 'Cat' then do SQL A , otherwise do SQL B.

    Is this where Selects inside of selects come into play? Is there another way to do this?

    Thanks,

    Kevin
    It's possible, each SQL flavor has their version. A good place to look is google "stored procedure (flavor of SQL) IF Then statement"

    Generally this is frowned upon as databases should avoid containing logic. But there was this time during the 90's when engineers went crazy with stored procedures and moved logic to the database in before map-reduce and distributed logic became easier to implement.
    David Lai
    SDET / Consultant
    LinkedIn profile

  3. #3
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Location
    Kew Gardens, United States
    Posts
    2,596
    Post Thanks / Like
    Blog Entries
    1
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    David,
    The SQL is for testing. I want to put it in a test case to say run a query and compare the output against some other data. I was hoping to avoid having to put in a lot of sentences saying Run SQL A. If the name is "kevin" then do query B for the next step. Otherwise do query C for the next step. I wont have a storage area for stored procedures.
    Any other ideas?
    Thanks,
    Kevin
    When in Florida, Don't Tampa with the code. I made this up.

  4. #4
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Location
    Kew Gardens, United States
    Posts
    2,596
    Post Thanks / Like
    Blog Entries
    1
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    I have more questions on this topic. I will start a new thread.
    Thanks,
    Kevin
    When in Florida, Don't Tampa with the code. I made this up.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 12.50%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 11:13 AM.

Copyright BetaSoft Inc.