SQL Server等在查询时,忽略查询条件后的空格,不忽略查询条件前的空格

下面数据库是SQL Server2008。Java中执行情况也同下面所列4种情况。

情形1:前后都没有空格:

select checknumber,betmoney,g.poscode,issue,number,p.ceganame,checksn,multitimes,p.status,tickmoney,p.status,p.poganame,checknumber

 from lot_wagertick as t  inner join lot_wagersn as k on t.wtid=k.wtid

  inner join lot_play as p on k.plid=p.plid 

  inner join lot_game as g on t.gaid=g.gaid where bettime=(select max(bettime) from lot_wagertick

    where stidin(select stid from sta_pos_change

   where ppid in(select ppid from pos_pos where imei='1094238784') ) )

    and t.type=1 and g.type=1 and g.status=1

 

 

 

 

情形2:前面没有空格,后面有空格:

select checknumber,betmoney,g.poscode,issue,number,p.ceganame,checksn,multitimes,p.status,tickmoney,p.status,p.poganame,checknumber

 from lot_wagertick as t  inner join lot_wagersn as k on t.wtid=k.wtid

  inner join lot_play as p on k.plid=p.plid 

  inner join lot_game as g on t.gaid=g.gaid where bettime=(select max(bettime) from lot_wagertick

    where stidin(select stid from sta_pos_change

   where ppid in(select ppid from pos_pos where imei='1094238784    ') ) )

    and t.type=1 and g.type=1 and g.status=1

 

 

 

情形3:前面有空格,后面没有空格:

select checknumber,betmoney,g.poscode,issue,number,p.ceganame,checksn,multitimes,p.status,tickmoney,p.status,p.poganame,checknumber

 from lot_wagertick as t  inner join lot_wagersn as k on t.wtid=k.wtid

  inner join lot_play as p on k.plid=p.plid 

  inner join lot_game as g on t.gaid=g.gaid  where bettime=(select max(bettime) from lot_wagertick

    where stidin (select stid from sta_pos_change

   where ppid in(select ppid from pos_pos where imei='   1094238784')) )

    and t.type=1 and g.type=1 and g.status=1

 

 

 

情形4:前后都有空格:

select checknumber,betmoney,g.poscode,issue,number,p.ceganame,checksn,multitimes,p.status,tickmoney,p.status,p.poganame,checknumber

 from lot_wagertick as t  inner join lot_wagersn as k on t.wtid=k.wtid

  inner join lot_play as p on k.plid=p.plid 

  inner join lot_game as g on t.gaid=g.gaid  where bettime=(select max(bettime) from lot_wagertick

    where stidin(select stid from sta_pos_change

   where ppid in(select ppid from pos_pos where imei='   1094238784   ') ))  and t.type=1 and g.type=1 and g.status=1


你可能感兴趣的:(SQLServer,SQL)