dtx3006 2014-11-25 05:15
浏览 38

如何从一半的数据中选择mysql表中的数据

I am getting data from form field. It contains

$city = "blr";
$field = "name";
$value= "mohai";


$sql = mysqli_query($con,"SELECT u.*, ad.*, ut.*, ci.*, st.* FROM user u, address ad, user_types ut, city ci, state st WHERE u.city_id=ci.id and ci.state_id=st.id and u.userId=ad.userId and 
    u.userType=ut.id and ci.city_name='".$city."' and u.".$field."='".$value."' and u.isDelete = '0'");

I am using above query for getting all data. Here my question is

user table has name field

For ex: the data is in user table-> "mohaideen"

If i give the name field mohai. It should filter the data from table.

How can i write a query for above functionality.

  • 写回答

4条回答 默认 最新

  • doufei1988 2014-11-25 05:25
    关注

    To search through a pattern use % sign in sql . your query would be some thing like below

    select from Table_name where some_property like modhi%;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题