现在有一个表,表中的信息不是一次全部填写完的,所以想问一下,能不能在判断表中的某个字段是否为空之后决定是否关联其他表,如果为空则不不与其他表关联,如果不为空则与其他视图关联!
解决方案 »
- 从php里执行的mysql语句无法插入数据表 但auto increment数值却在增加 请问是什么问题?
- 创建触发器错误。在线等待,在线结帖。
- 插入数据时,重复数据只插入一次
- 就特定需求征求解决方案
- MySQL字符过滤问题?
- 求教mysql5.0.18-win32安装版下如何进入mysql的交互操作界面mysql>?实在不会了
- DELPHI如何连接POSTGRESQL ?
- 有没有什么方法能让这样的语句在mysql里执行
- 还是中文问题??????
- win2008 64bit下,mysql odbc连接数据出错?
- 怎样转换一个IP地址格式的字符串?
- com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException
建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
1. 你的 create table xxx .. 语句
2. 你的 insert into xxx ... 语句
3. 结果是什么样,(并给以简单的算法描述)
4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。
(
id1 varchar(10),
name1 varchar(20),
name2 varchar(20)
)
insert into test1 select '01',空,‘b1’
insert into test1 select '02','a2','b2'create table test2
(
id2 varchar(10),
name3 varchar(20),
name4 varchar(20))
insert into test2 select '01','a1','c1'
insert into test2 select '04','a2','c2'希望建立视图得到
01 空 b1 空
02 a2 b2 c2
就是想在test1的name1不为空时与test2关联 得到name4 为空时对应的列显示为空
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '空,‘
b1’' at line 1楼主,你的语句自己有试过吧?能执行吗? 建议不要乱贴无法使用的东西,浪费别人的时间的同时也浪费自己的时间。
-> From test1 left join test2 on test1. Name1= test2. name3
-> ;
+------+-------+-------+-------+
| id1 | name3 | name2 | name4 |
+------+-------+-------+-------+
| 01 | NULL | b1 | NULL |
| 02 | a2 | b2 | c2 |
+------+-------+-------+-------+
2 rows in set (0.00 sec)mysql>