Search multiples tables with different column names for a string

freeaks

i wanted to ask, how is it in sql to search multiple tables with different column names for a given string ? i know for 1 table it's:

select * from table where column like '%string%' 

... but for searching multiple tables (with different column names) for that same string ? i'm searching something like this:

select * from table1,table2 where table1.column and table2.column like '%string%'

so it would search in table1.column and table2.column for that specific string is it possible ?

xQbert

This would be the typical way.

select * from table1,table2 
where table1.column like '%string%'
OR table2.column like '%string%'

OR perhaps slightly more efficient

This will likely result in a slight performance gain as it doesn't have to "search twice" as the "OR" notation would have to. The overhead of the string concat is likely less than the overhead of doing a full table scan again. which %txt% will have to do.

select * from table1,table2 
where concat(table1.column, table2.column) like '%string%'

Incidentally this is doing a cross join between tables... are you sure this is how the join should operate? usually there's a key relationship between them.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Joining tables based on different column names

From Dev

Get the different column names on two tables MySQL

From Dev

Get the different column names on two tables MySQL

From Dev

SQL UNION two tables with different column names

From Dev

SQL select rows from two different tables with different column names

From Dev

In Oracle, how do you search a tables' column-names?

From Dev

In Oracle, how do you search a tables' column-names?

From Dev

Join tables by column names, convert string to column name

From Dev

How to join different tables in sqlalchemy query having same column names?

From Dev

Map class to tables with different table names but same column structure

From Dev

Trying to retrieve names from 'name column' from two different tables

From Dev

Join two tables with different column names and same rows

From Dev

Excel VBA SQL UNION SUM with GROUP BY on Tables with Different Column Names

From Dev

Search for string in names of all tables in sql management studio 2008

From Dev

search for column names in oracle

From Dev

SQL that will search for a string and return a different string in the column next to it?

From Dev

Calculate difference of column pairs with nearly identical names (different last string)

From Dev

Different width of column in tables

From Dev

How to check if a given data exists in multiple tables(all different column names)

From Dev

grep() to search column names of a dataframe

From Dev

Search on multiple tables with different columns

From Dev

Concatenate a string to column names

From Dev

LINQ search similar string(names)

From Dev

Search file names that contain a string

From Dev

Search data from two different tables that two tables in different databases

From Dev

subsetting data tables by dynamic column names

From Dev

Joining three tables in Laravel with conflicting column names

From Dev

unique column names for a list of data tables

From Dev

Merge multiple data tables with duplicate column names

Related Related

  1. 1

    Joining tables based on different column names

  2. 2

    Get the different column names on two tables MySQL

  3. 3

    Get the different column names on two tables MySQL

  4. 4

    SQL UNION two tables with different column names

  5. 5

    SQL select rows from two different tables with different column names

  6. 6

    In Oracle, how do you search a tables' column-names?

  7. 7

    In Oracle, how do you search a tables' column-names?

  8. 8

    Join tables by column names, convert string to column name

  9. 9

    How to join different tables in sqlalchemy query having same column names?

  10. 10

    Map class to tables with different table names but same column structure

  11. 11

    Trying to retrieve names from 'name column' from two different tables

  12. 12

    Join two tables with different column names and same rows

  13. 13

    Excel VBA SQL UNION SUM with GROUP BY on Tables with Different Column Names

  14. 14

    Search for string in names of all tables in sql management studio 2008

  15. 15

    search for column names in oracle

  16. 16

    SQL that will search for a string and return a different string in the column next to it?

  17. 17

    Calculate difference of column pairs with nearly identical names (different last string)

  18. 18

    Different width of column in tables

  19. 19

    How to check if a given data exists in multiple tables(all different column names)

  20. 20

    grep() to search column names of a dataframe

  21. 21

    Search on multiple tables with different columns

  22. 22

    Concatenate a string to column names

  23. 23

    LINQ search similar string(names)

  24. 24

    Search file names that contain a string

  25. 25

    Search data from two different tables that two tables in different databases

  26. 26

    subsetting data tables by dynamic column names

  27. 27

    Joining three tables in Laravel with conflicting column names

  28. 28

    unique column names for a list of data tables

  29. 29

    Merge multiple data tables with duplicate column names

HotTag

Archive