请教一个问题:mysql中,我查询语句
select * from tableA where name='test' and age='18';
然后我有一个name和age的list列表,分别通过这两个条件去查询,有什么比较方法可以查询;
eg:
select * from tableA where name='test' and age='18';
select * from tableA where name='test1' and age='18';
select * from tableA where name='test2' and age='20';
select * from tableA where name='test2' and age='56';
···
其中查出来的数据对应Java的一个实体。其中List表的大小为500-3000,数据表的记录为每天8万左右
Create a view query, which will be more efficient. At least slightly faster than temporary tables
table A adds a column named nameage. The value in it is the combination of name and age. For example, test18
select * from tableA where nameage in ('test18','xxxxxx','xxxxxxx')
Of course you don’t need to add columns, you can also write it in SQL yourself
togeek’s answer is very cool
You may want to consider the efficiency of sql again
No way?
When the amount of data is not large, you can do this.
But by explaining the above query, you will find that this way of writing cannot use the index, so the query efficiency is very low.
Create a temporary table and join 2 fields in the temporary table
http://stackoverflow.com/ques...
http://www.zhihu.com/question...