佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

搜索
查看: 1693|回复: 5

重要:SQL

[复制链接]
发表于 13-11-2010 12:14 AM | 显示全部楼层 |阅读模式
select AgentCode,AgentName,Address,poskod.Postcode,negeri.City,State
                        from agent,alamat,poskod,negeri
                        where agent.AgentCode=alamat.Code
                        and alamat.Postcode=poskod.Postcode
                        and poskod.City=negeri.City order by agent.AgentCode

Result:
s100      xxx  123, jalan m  06150  ayer hitam  johor
s100      xxx  123, jalan m  06150  ayer hitam  kedah

请问要怎样让johor的那个不要show出来,因为他的poskod是不对的。
回复

使用道具 举报


ADVERTISEMENT

发表于 13-11-2010 12:26 AM | 显示全部楼层
where poskod.City <> 'johor'
回复

使用道具 举报

 楼主| 发表于 13-11-2010 12:34 AM | 显示全部楼层
回复 2# onlylonly

谢谢你。可是我还有show database里全部的data。

Example:
s100   xxx   123, jalan m,   06150  ayer hitam   kedah
s101   yyy   456, taman k,  16800  pasir puteh  kelantan
s102   zzz   789, jalan p,    81800  ulu tiram     johor

所以这是行不通。
回复

使用道具 举报

发表于 13-11-2010 12:42 AM | 显示全部楼层
where poskod.City <> 'johor' AND poskod.Postcode <> '06150'

我不懂你的 postcode 是 string 还是 numeric。。 我把它当成是 string
回复

使用道具 举报

 楼主| 发表于 13-11-2010 11:04 AM | 显示全部楼层
where poskod.City  'johor' AND poskod.Postcode  '06150'

我不懂你的 postcode 是 string 还是 numeri ...
onlylonly 发表于 13-11-2010 12:42 AM


我的postcode是string的。因为如果放numeric的话,06150就会变成了6150,对吗?你说放where poskod.City  'johor' AND poskod.Postcode  '06150',这样的话,凡是有johor and 06150的就不会出来了,是吗?
对不起,我才刚学,所以有很多都不会,问的问题也会白痴一点。
回复

使用道具 举报

发表于 13-11-2010 11:30 AM | 显示全部楼层
本帖最后由 onlylonly 于 13-11-2010 11:35 AM 编辑

没错, 凡是同时poscode是 06150 与同时是 johor 都不会受出来。。

其实 numeric 也可以 06150 的, 比如说在 mysql

create table test (
poscode integer(5) ZEROFILL not null PRIMARY KEY );

INSERT INTO test(poscode) values(1234);

SELECT * from test;

你会发现
+---------+
| poscode |
+---------+
|   01234 |
+---------+
回复

使用道具 举报

Follow Us
您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT


本周最热论坛帖子本周最热论坛帖子

ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2026 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 22-5-2026 10:34 PM , Processed in 0.074583 second(s), 11 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表