Thread: special queries for databases

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    46

    special queries for databases

    Hi i made an application in BCB6 for save records in database
    I have one field pSize and i made the above query:

    ADODataSet1->CommandText= "SELECT * FROM Pictures WHERE pSize>="+Edit1->Text;

    With this query user type a size in Edit1->Text and in DBgrid gets all the records that have bigger size from Edit1->Text

    Now i have 2 questions

    1)How i can do the above by using 2 Edit1->Text and Edit2->Text so the user can find records between 2 sizes
    2)How i can return in DBGrid the record with MAX size and MIN size

    All i ask is the syntax in my two questions in Command->Text
    Thanks

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Such questions should be asked on the SQL forum... They have nothing to do with C++

    Code:
    SELECT * FROM Pictures WHERE pSize >= 0 AND pSize <= 50
    SELECT * FROM Pictures WHERE pSize = (SELECT MAX(pSize) FROM Pictures)
    If the second one is not working in your dialect of SQL following form can be tried
    Code:
    SELECT * FROM Pictures WHERE pSize IN (SELECT MAX(pSize) FROM Pictures)
    If this is not working also - you can run 2 selects - first requests the maximum psize value and stores it in the temporary var
    Second uses this temp var to select the record with corresponding value for pSize (it can be several - so you should be aware of this)
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    46
    Dear stranger.
    My problem wasnt the theory part (SQL Basics) but how i will make them in practise in C++( with all "" and ').. But thanks anyway you helped

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing a special type?
    By blernblan in forum C Programming
    Replies: 1
    Last Post: 06-02-2009, 03:35 PM
  2. locking actions to special threads
    By pheres in forum C++ Programming
    Replies: 2
    Last Post: 09-24-2008, 10:17 AM
  3. special characters removing from srting
    By cnu_sree in forum C Programming
    Replies: 5
    Last Post: 06-06-2007, 08:30 PM
  4. special function detection
    By zyd in forum C Programming
    Replies: 7
    Last Post: 02-28-2006, 03:25 PM
  5. Special (non) Keyboard Characters
    By TechWins in forum C++ Programming
    Replies: 3
    Last Post: 05-01-2002, 12:08 AM