duanmeng3126 2014-12-30 06:43
浏览 15
已采纳

错误:加入MySql,PHP

I have two tables in mysql one is quote and the fields are quote_id, status, created and submit_by. in submit_by field i am saving username of the employee and in employee table the fields are firs_name, last_name, username, password. I want to show in a php table the employee first name instead of username of the employee.

full quote table stucture

enter image description here

full employee table sructure

enter image description here

this is the code i am using but not getting any result

$sql = "SELECT q.quote_id, q.client_name, q.status, e.first_name 
        FROM `quote` AS q 
        LEFT JOIN `employee` AS e ON q.submit_by = e.username";
  • 写回答

3条回答 默认 最新

  • 普通网友 2015-01-03 09:37
    关注

    Use this one

    $sql = "SELECT * , employee.first_name FROM quote 
    LEFT JOIN employee ON quote.submit_by = employee.username ORDER BY quote.client_name";
    $result = $dbLink->query($sql);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 用C语言实现语音的读取及播放
  • ¥15 poi怎么在指定位置之后生成多个表格
  • ¥15 nginx在location设置了client_max_body_size依旧报错413
  • ¥15 C#添加WCF服务引用客户端调用方法没有反应
  • ¥15 stm32f103c8t6与esp8266
  • ¥15 使用Hadoop的MapReduce program
  • ¥15 Python发生IndexError错误如何解决?
  • ¥15 如何用matlab搭建激光器
  • ¥15 51单片机两路互补SPWM输出全桥逆变
  • ¥15 outlook左边用户名下拉为啥打不开了