Computing.Net > Forums > Database > selecting a row from a table

selecting a row from a table

Reply to Message Icon

Original Message
Name: trichyselva
Date: August 30, 2006 at 03:35:40 Pacific
Subject: selecting a row from a table
OS: windows
CPU/Ram: p4
Model/Manufacturer: pentium
Comment:

if i have a table with entries like
1 2 342
1 3 532
1 4 555
1 7 222
2 1 333
2 2 332

now i want
1 4 555
2 1 333
to be displayed

how to do it


Report Offensive Message For Removal

Response Number 1
Name: StuartS
Date: August 30, 2006 at 04:44:19 Pacific
Subject: selecting a row from a table
Reply: (edit)

More information needed. What are you using to access the database? What format is the database in?

Whatever you are using, it is unlikely that you will be able to retrieve the two records you mention with a single query as there is no similarity between them. You will have to use two separate queries.

Stuart


Report Offensive Follow Up For Removal

Response Number 2
Name: Michael J (by mjdamato)
Date: September 1, 2006 at 07:43:27 Pacific
Subject: selecting a row from a table
Reply: (edit)

Two separate queries are not needed. That's what OR is for. In a SQL type database it would go something like this (assuming the names of the columns are C1, C2, & C3):

SELECT * FROM table_name
WHERE (C1=1 AND C2=4 AND C3=555)
   OR (C1=2 AND C2=1 AND C3=333)

Ideally, though, each record would have a unique id so that you don't have to get that granular in the select statement.

Michael J


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: selecting a row from a table

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software