0

Can any one tell me why my query is returning empty. I am pretty new to postgreSQL and I'm not sure if I'm accessing the two arrays correctly. I also tried a subquery with status.

Here is the query:

SELECT * FROM piecedef pd, pieceinst pi 
WHERE pi.truckno IN ('29,26,25,2,16,15,14,13,12,11,10')
AND pi.status IN (3601,102,201)        
AND pi.defid=pd.pdid
AND pd.projectid='4592'
ORDER BY pi.piid

truckno is a varchar (15) and status is int4 (32). Thanks in advance!

1 Answer 1

2

Try

SELECT * FROM piecedef pd, pieceinst pi
WHERE pi.truckno IN ('29','26','25','2','16','15','14','13','12','11','10') 
AND pi.status IN (3601,102,201)        
AND pi.defid=pd.pdid
AND pd.projectid='4592'
ORDER BY pi.piid

What your error seems to be: an array of varchar needs each element between quotes, otherwise it will be considered as on eelement of a long varchar...

Sign up to request clarification or add additional context in comments.

1 Comment

Nicely done working that out without any table data, schema, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.