mysql查询sql语句
mysql有表A:
id num
1 4
2 9
3 14
4 20
5 25
表B:
id start end
1 0 5
2 6 10
3 11 15
怎么能查询到存在于表B中任一的start字段和end字段之间的数?
比如 表A中的4,9,14都是在表b两个字段之间的数,而20和25因为没有在表b任一字段之间所以无法查询出来..select a.* from a inner join b
on a.num between b.start and b.enf
SQL code:
mysql> select * from a;
+----+------+
| id | num |
+----+------+
| 1 | 4 |
| 2 | 9 |
| 3 | 14 |
| 4 | 20 |
| 5 | 25 |
+----+------+
5 rows in set (0.00 sec)
mysql> select * from b;
+----+-------+------+
| id | start | end |
+----+-------+------+
| 1 | 0 | 5 |
| 2 | 6 | 10 |
| 3 | 11 | 15 |
+----+-------+------+
3 rows in set (0.00 sec)
mysql> select a.id,num from a,b where a.id=b.id and a.num between b
-> .start and b.end;
+----+------+
| id | num |
+----+------+
| 1 | 4 |
| 2 | 9 |
| 3 | 14 |
+----+------+
3 rows in set (0.02 sec)
SQL code:
selec
相关问答:
环境:1.win2003server+oracle9i
2.oracle9i字符集为AMERICAN_AMERICA.WE8ISO8859P1
3.oracle sql developer版本 1.5.5
现象描述: 1.在sql developer 中查询oracle中的某个表,中文全部显示为乱码。 ......
表如下
教室ID 座位数 开始时间 结束时间 2009年1月1日 2009年1月2日 2009年1月3日
101 50 08:00 08:30 30 40 50
101 50 09:00 ......
MySql中插入当前时间的该怎么写啊?
now()
SQL code:
sql里是:
getdate()
引用
now()
学习
SQL code:
select now();
SQL code:
TODAY()
?
SQL code:
select now();
/* ......
环境:win2003 apache2 resin3 php5 mysql5
mysql错误里出现这个,服务器直接死到那里。
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_log ......
我有一个java环境下的程序,在本机运行正常,但发布到网的虚拟主机时不能连接数据库连接池
jdk 1.6 tomcat6.0.18 mysql5 mysqljdbc5.1.5
虚拟主机的技术人员说,只能配置局域的数据库连接池,也就是在M ......