Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL querying two tables lots of columns
    primarykey
    data
    text
    <p>I have two tables which have all the same columns but different data. They represent two different days. The tables are D1Table and D2Table. The columns are author1, author2, author3, author4, author 5, position1 - position5, title and biography- biography5. In the query I am trying to get the columns that match the text typed into a text box by a user (so they can do a search on both days).</p> <p>What I have so far works fine on the first table but I really want to search both the first and second table, I just don't know how to, I have tried using join and union but I haven't had much luck I just get errors obviously I am doing something wrong. Also the query I am using is really long as you can see, I am sure there must be a better way to do this:</p> <pre><code>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 + "%' "; </code></pre> <p>Now I know this is pretty awful and as you can probably tell I am rubbish with SQL queries (I am just starting to learn them). I have been looking all over the internet for some time trying to learn the syntax but this is as far as I have got, so I thought it was probably about time I asked for help. If anyone can give me some guidance it would be much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload