# Miscellaneous > SQL Scripts >  SQL query

## relaxedgalaxy

Hi, 
I have a table storing data like this

Oid	OKey		OValue
1	Status		Open
1	Priority		1
1	Name		TTT
1	Location	NYC
2	Status		Open
2	Priority		2
2	Name		TYY
2	Location	WDC
3	Status		Close
3	Priority		2
3	Name		TYZ
3	Location	WDC

Now, I need to write a query to fetch Oids with Okey Priority=2 and Okey Location=WDC

Kindly suggest

----------


## rmiao

Select * from table where (okey = 'Priority' and ovalue = '2') and (okey = 'Location' and ovalue = 'WDC')

----------


## anwarul.haque

1. SELECT * FROM TABLENAME WHERE Priority=2 AND Location='WDC'

----------


## rmiao

In this case, Priority and Location are values in column okey. WDC and 2 are values of ovalue column.

----------


## anwarul.haque

Let me show your table structure with values
Its easier for me to expalin.

Cool

----------


## JereArtity

Not knowing the database structure means that it will be impossible to give a precise answer, but in general
Open SQL Server Management Studio
Click the NEW QUERY button
Type USE <name of database>
Click Execute
Type SELECT  FROM <name of table containing client list>
Click Execute

----------

