1

I have two table table 1 and table 2.

Table 1 have four field.

  1. cId
  2. fname
  3. lName
  4. userId

Table 2 have four field.

  1. qId
  2. CKId
  3. category
  4. desc

In both table cId and cKID is common, they have customer Id.

I need to combine both table data and orderby fname. How can I achieve that ?

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
Chirayu Vyas
  • 67
  • 11

1 Answers1

1

What you want is called inner join and is given in the mysql manual.

SELECT cid,fname,iname, userid, qid, category, `desc` 
 FROM table1 inner join table2 on table1.cid = table2.ckid order by fname

you don't want to use 'desc' as a column name because it is confusion. DESC means descending in a query clause. So if possible try to rename that field in your table

middlestump
  • 1,035
  • 8
  • 22