I'm having trouble executing this SQL statement and getting the data back that I need.
I have a table that has duplicate rows (kind of)... One of the duplicate row has data in 2 columns that I need.
partial example:
Id Batch_Num Invoice_Num SEQ_Num Acct_Num Misc status_code
--------------------------------------------------------------------------------
1 20010001 0003 45 2
2 20010001 3456 89877 10
3 20020002 0004 88 2
4 20020002 4667 34566 10
*** my example table formatting is lost when I submit here is a screen shot:
[ATTACH]4711[/ATTACH]
$sql = "SELECT a.id, a.batch_num, a.seq_num, a.acct_num, b.batch_num, b.invoice_num, b.seq_num
FROM myfile a, myfile b
WHERE
a.batch_num = b.batch_num
AND a.status_code = '2' ";
So, I need to get all of the info where the batch_num's are equal and the a.status_code = 2....
I'm not sure what I am missing here? Would I be better off doing a sub_query of some sort?
I appreciate any insight... Thanks!
Screen Shot 2012-10-26 at 2.25.09 PM.png