dsizmmwnm56437180 2011-01-25 06:59
浏览 50

如何使PHP中的MSSQL查询区分大小写?

In a script on our web server, we display users who are online in-game by looking at a MSSQL database for specific values then displaying the members based on such data.

Lets say user login 'blargh' has 3 characters: MasteR, MasTeR, and BlarGh
Lets also say that he has logged in as 'MasteR'

The below script will look for the value of '1' in 'connectstat' field then grab his username along with some other pertinent data, then display it.

The problem lies when someone has two similar in-game names on a single account.

With the above example, this script will show MasteR, and MasTeR are both online, even though only one is actually in-game. I believe this is a case sensitivity issue where when it identifies 'MasteR' as online, it's ignoring the case and believes 'MasTeR' is online as well.

Anyone have ideas on how to isolate this by making it case-sensitive?

$query = 'Select GameIDC, Resets, Class, MapNumber, MapPosX, MapPosY, ServerName, OnlineHours, clevel From MEMB_STAT, AccountCharacter, Character where MEMB_STAT.Connectstat=1 and AccountCharacter.Id=MEMB_STAT.memb___id AND AccountCharacter.GameIDC=Character.Name collate Chinese_PRC_CI_AS order by GameIDC, ServerName desc';

$result = mssql_query($query);

This is on a xampp-based web server on winxp x86 using php5 and MSSQL (ODBC)

  • 写回答

1条回答 默认 最新

  • doudou5101 2011-01-25 07:40
    关注

    case sensitivity comes from collation. so if the collation is set as cs (case sensitive) then your query condition will be CS as well.
    however, why dont you try to use group by
    ie. select playername from gameDb where status=1 group by playername;

    评论

报告相同问题?

悬赏问题

  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了