我现在有两个表:information和category.两个表的字段如下:
information表中的字段:
cl_number(车辆序号),cph(车牌号),sj(车主手机号),cl_type_xh(车辆类别序号).
category表中的字段:
cl_type_xh(车辆类别序号),type_name(类型名称).现在我想在输入了车牌号后查询,查到车辆类别序号.得到车牌号所对应的type_name(类型名称).可不可以写在一句SQL里面.应该怎么写.求大家帮助了.

解决方案 »

  1.   

    select cl_number,cph,sj,info.cl_type_xh,type_name
    from information as info,category as cate
    where info.cl_type_xh=cate.cl_type_xh and cph='00001'
      

  2.   

    问一下呢.车牌号我是在VB里面的文本框输入的.cph='00001'是什么意思??
      

  3.   

    strsql="select cl_number,cph,sj,info.cl_type_xh,type_name
    from information as info,category as cate
    where info.cl_type_xh=cate.cl_type_xh and cph='"& text1.text &"'"
      

  4.   

    我的两个表:information和category.两个表的全部字段如下,刚才没有写完:
    information表中的字段:
    cl_number(车辆序号),cph(车牌号),sj(车主手机号),cl_type_xh(车辆类别序号),in_time(入场时间),out_time(出场时间),flag(出场标志),in_yg_id(入场经办人),out_yg_id(出场经办人).
    category表中的字段:
    cl_type_xh(车辆类别序号),type_name(类型名称).这样写对不?
    sql = "select cl_number,cph,sj,in_time,out_time,flag,in_yg_id,out_yg_id info.cl_type_xh,type_name from information as info,category as catewhere info.cl_type_xh=cate.cl_type_xh and cph=Trim(txtcar.Text) & " And " & flag = 0 "
      

  5.   

    sql = "select cl_number,cph,sj,in_time,out_time,flag,in_yg_id,out_yg_id info.cl_type_xh,type_name from information as info,category as cate where info.cl_type_xh=cate.cl_type_xh and cph='"& Trim(txtcar.Text) & "' And  flag = 0 "
      

  6.   

    这样就把category表里的type_name(类型名称)取出来是吧!
      

  7.   

    我用的是ACCESS数据库.不是SQL呀