0

i have two tables named files, director. i want to select all data from director and select two columns from files this is code

$acc_no=$_POST['acc_no'];
$q="select * from files,director_recovery where account_no='$acc_no'";
Strawberry
  • 33,750
  • 13
  • 40
  • 57
  • 6
    Possible duplicate of [How to join two tables mysql?](http://stackoverflow.com/questions/3536283/how-to-join-two-tables-mysql) – Marc Nov 05 '16 at 08:41
  • First of all give the table structure.It is similar to http://stackoverflow.com/questions/9806097/how-to-fetch-data-from-two-tables-in-sql. – Bibhudatta Sahoo Nov 05 '16 at 09:24

1 Answers1

0

For selecting data from 2 tables you can use JOIN

SELECT director_recovery.*, files.col1, files.col2 
  FROM director_recovery 
  JOIN files on files.account_no = $acc_no

I think this may help you

Ponnarasu
  • 635
  • 1
  • 11
  • 24
Punabaka Abhinav
  • 502
  • 1
  • 9
  • 17