special queries for databases

This is a discussion on special queries for databases within the Windows Programming forums, part of the Platform Specific Boards category; Hi i made an application in BCB6 for save records in database I have one field pSize and i made ...

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

    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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,474
    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)
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    43
    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, 02:25 PM
  5. Special (non) Keyboard Characters
    By TechWins in forum C++ Programming
    Replies: 3
    Last Post: 05-01-2002, 12:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21