列的我有全部具有相同的列,但不同数据的两个表。他们代表两个不同的日子。这些表格是D1Table和D2Table。这些列是author1,author2,author3,author4,author5,position1 - position5,title和biography- biography5。在查询中,我尝试获取与用户输入文本框中的文本相匹配的列(以便他们可以在两天内进行搜索)。SQL查询两个表很多
我至今工作于第一个表不错,但我真的想同时搜索第一和第二个表,我只是不知道如何,我曾尝试使用和加入工会,但我没有很幸运,我只是得到错误,显然我做错了什么。此外,我现在用的查询是很长的,你可以看到,我肯定必须有一个更好的方式来做到这一点:
txt = "SELECT * from D1Table WHERE Synopsis LIKE '%" + txtBText +
"%' OR Author1 LIKE '%" + txtBText + "%' OR Author2 LIKE '%" + txtBText +
"%' OR Author3 LIKE '%" + txtBText + "%' OR Author4 LIKE '%" + txtBText +
"%' OR Author5 LIKE '%" + txtBText + "%' OR Biography1 LIKE '%" + txtBText +
"%' OR Biography2 LIKE '%" + txtBText + "%' OR Biography3 LIKE '%" + txtBText +
"%' OR Biography4 LIKE '%" + txtBText + "%' OR Biography5 LIKE '%" + txtBText +
"%' OR Title LIKE '%" + txtBText + "%' OR Position1 LIKE '%" + txtBText +
"%'OR Position2 LIKE '%" + txtBText + "%' OR Position3 LIKE '%" + txtBText +
"%' OR Position4 LIKE '%" + txtBText + "%' OR Position5 LIKE '%" + txtBText + "%' ";
现在我知道这是很可怕的,正如你也许能告诉我垃圾与SQL查询(我刚开始学习它们)。我一直在寻找整个互联网一段时间,试图学习语法,但这是我所知道的,所以我认为这可能是我要求帮助的时候。如果任何人都可以给我一些指导,将不胜感激。
这看起来很有趣,我会考虑这样做,感谢您的链接。 – OverHere 2012-04-29 17:08:27