我如何使用PHP,mysql解决这个问题。 [英] How do I solve this using PHP, mysql.

查看:99
本文介绍了我如何使用PHP,mysql解决这个问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中有三个表。第一个表有主键indno(自动增量),第二个表有indno ad外键和sn作为主键(AI),第三个表有sn作为外键,id作为主键(AI)。

我在html中创建了一个表单,并使用php,sql从用户那里插入值。我想编写查询以将之前的结果提取到表单中,以便登录的用户可以更改并更新数据,如果他/她使用的话。



我尝试了什么:



查询中有错误。

i used- SELECT * FROM sailform6,sailform7,sailform8其中indno = $ indno;

和形式我使用的值=

I have three tables in a database. First table has primary key indno(auto increment), second table has indno ad foreign key and sn as a primary key(AI), third table has sn as foreign key and id as primary key(AI).
I made a form in html and and inserted values in that form from user using php,sql. I want to write query to fetch previous result into the form so that the logged in user may change and update the data if he/she whises to.

What I have tried:

There is an error in query.
i used- SELECT * FROM sailform6,sailform7,sailform8 where indno=$indno";
and in the form i used value= ""

推荐答案

indno;

和我使用的形式value =
indno";
and in the form i used value= ""


你需要使用JOINS。



SELECT *

来自sailform6 s6

LEFT JOIN sailform7 s7 ON s6.indno = s7.indno

LEFT JOIN sailform8 s8 ON s6.indno = s8.sn
You need to use JOINS.

SELECT *
FROM sailform6 s6
LEFT JOIN sailform7 s7 ON s6.indno = s7.indno
LEFT JOIN sailform8 s8 ON s6.indno = s8.sn


首先,了解 SQL连接的可视化表示 [ ^ ] <无线电通信/>
后跟多个联接如何工作 [ ^ ]
First, learn about Visual Representation of SQL Joins[^]
followed by How Multiple Joins Work[^]


这篇关于我如何使用PHP,mysql解决这个问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆