下面是两张表Vehicle
和vehicle_owner
VEHICLE_OWNER 表
**Oid Oname Oage Oaddress**
1 Ahsan 22 house 80/3 street no 22 rawalpindi
2 Arslan 23 House no 56-C F6/2 Islamabad
车辆表
**Vregno Vname Vmakername Vtype Vyear Vstatus V_oid**
FSM393 Mehran Suzuki Car 2006 Clear 1
RLA3725 City Honda Car 2013 Stolen 2
代码:
PreparedStatement p = conn.prepareStatement("select Vstatus,Oname from Vehicle_Owner LEFT OUTER JOIN Vehicle ON vehicle_owner.Oid= Vehicle.V_oid where Vregno='"+ss+"'");
ResultSet r=p.executeQuery();
while(r.next()) {
vstatus=r.getString("Vstatus");
oname=r.getString("Oname");
System.out.println("Vehicle Status= "+vstatus+"<br>");
System.out.println("Owner name= "+oname+"<br>");
}
我想根据车辆注册号显示 Oname 和 Vstatus。(Vregno) 我正在使用这个查询,但它在 MYSQL 中不起作用
select Vstatus,Oname from Vehicle_Owner INNER JOIN Vehicle ON vehicle.V_oid= vehicle_owner.Oid AND Vregno="FSM393";
任何人请帮助我