SELECT DISTINCT input.gsum, goods.gname, stock.gno, goods.gunit, goods.gsort, store.sname
FROM store INNER JOIN((goods INNER JOIN stock ON goods.gid=stock.gid) INNER JOIN [input] ON goods.gid=input.gid) ON (store.sid=stock.sid) AND (store.sid=input.sid)
WHERE (((goods.gsort) Like '*' & forms!出库单!gsort & '*') And ((goods.gname) Like '*' & forms!出库单!gname & '*') And ((store.sname) Like '*' & forms!出库单!sname & '*') and ((input.gsum)=(stock.gsum)));
求教下这些语句的大致意思。DISTINCT返回唯一的值,那是从store表里返回这些input.gsum, goods.gname, stock.gno, goods.gunit, goods.gsort, store.sname的值嘛?INNER JOIN之后的语句我表示不明白。。帮帮忙,谢谢
------解决方案--------------------
'*'在SQL中还真没有怎么用过,但在VBA中可以代表一串字符和SQL中的%差不多。不知道回答对没有。
下面是LIKE中常用的字符:
- SQL code
Like ‘%mr%’--------包含字符mr的任何文本;Like ‘mr%’-----------以字符mr开头的任何文本;Like ‘%mr’------------以字符mr结尾的任何文本;使用’_’匹配任意单个字符;使用’[]’匹配某一范围的字符:[a-m]表示a到m的所有字符,[0-9]表示0到9的所有数字;使用’[^]’匹配非某一范围的字符;
------解决方案--------------------
- SQL code
select distinct input.gsum, goods.gname, stock.gno, goods.gunit, goods.gsort, store.snamefrom store inner join((goods inner join stock on goods.gid=stock.gid) inner join [input] on goods.gid=input.gid) on (store.sid=stock.sid) and (store.sid=input.sid)where (((goods.gsort) like '*' & forms!出库单!gsort & '*') and ((goods.gname) like '*' & forms!出库单!gname & '*') and ((store.sname) like '*' & forms!出库单!sname & '*') and ((input.gsum)=(stock.gsum)));--这个明显在SQL SERVER 中语法通不过(&和!的用法不符合SQL SERVER语法)--inner join 是内连接--on 是连接条件--where 是过滤条件--like 是模糊查询