Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

sql-like

SQL SELECT WHERE string ends with Column

May 7, 2023 by Tarik

You can use such query: SELECT * FROM TABLE1 WHERE ‘value’ LIKE ‘%’ + DomainName

Categories sql Tags select, sql, sql-like, sql-server Leave a comment

LIKE with % on column names

May 7, 2023 by Tarik

Try this SELECT * FROM account_invoice,sale_order WHERE sale_order.name LIKE ‘%’ || account_invoice.origin || ‘%’ % needs single quote because the pattern is a string. || is the operator for concatenation.

Categories postgresql Tags postgresql, sql-like Leave a comment

Create hive table using “as select” or “like” and also specify delimiter

May 6, 2023 by Tarik

Create Table as select (CTAS) is possible in Hive. You can try out below command: CREATE TABLE new_test row format delimited fields terminated by ‘|’ STORED AS RCFile AS select * from source where col=1 Target cannot be partitioned table. Target cannot be external table. It copies the structure as well as the data Create … Read more

Categories hive Tags create-table, hive, sql-like Leave a comment

SQL LIKE with no wildcards the same as ‘=’?

May 4, 2023 by Tarik

As @ocdecio says, if the optimizer is smart enough there should be no difference, but if you want to make sure about what is happening behind the scenes you should compare the two query’s execution plans.

Categories sql Tags sql, sql-like, wildcard Leave a comment

Python SQLite parameter substitution with wildcards in LIKE

May 1, 2023 by Tarik

The quotes protect either ? or :name from being taken as a place-holder — they’re taken literally. You need to place the percent signs around the string you’re passing, and use the plain placeholder without quotes. I.e.: self.cursor.execute( “select string from stringtable where string like ? and type = ?”, (‘%’+searchstr+’%’, type)) Note that neither … Read more

Categories python Tags python, sql-like, sqlite Leave a comment

PostgreSQL: Select data with a like on timestamp field

April 30, 2023 by Tarik

It’s all very well not “wanting to use” < and > with timestamps, but those operators can be converted into index scans, and a string-match… well, it can, but EWWWW. Well, the error is occurring because you need to explicitly convert the timestamp to a string before using a string operation on it, e.g.: date_checker::text … Read more

Categories postgresql Tags postgresql, sql-like, timestamp Leave a comment

MySQL starts with searching issue

April 27, 2023 by Tarik

Underscore is a wildcard for a single character. You will need to change your SQL to something like: WHERE fieldName LIKE ‘1%’ Or you can escape the underscore WHERE fieldName LIKE ‘1\_%’

Categories mysql Tags mysql, sql, sql-like Leave a comment

‘LIKE (‘%this%’ OR ‘%that%’) and something=else’ not working

April 22, 2023 by Tarik

It would be nice if you could, but you can’t use that syntax in SQL. Try this: (column1 LIKE ‘%this%’ OR column1 LIKE ‘%that%’) AND something = else Note the use of brackets! You need them around the OR expression. Without brackets, it will be parsed as A OR (B AND C),which won’t give you … Read more

Categories mysql Tags mysql, sql, sql-like Leave a comment

NOT LIKE and LIKE not returning opposite result

April 20, 2023 by Tarik

Does this return the correct result ? Select * from tbl1 WHERE COALESCE([TextCol],’-1′) NOT LIKE ‘%TAX%’ I believe NULL values are the issue here, if the column contains them, then NULL NOT LIKE ‘%TAX%’ will return UNKNOWN/NULL and therefore won’t be selected. I advise you to read about handling with NULL values , or here. … Read more

Categories sql Tags sql, sql-like, sql-server, tsql Leave a comment

MySQL join query using like?

April 7, 2023 by Tarik

Try SELECT * FROM Table1 INNER JOIN Table2 ON Table1.col LIKE CONCAT(‘%’, Table2.col, ‘%’) MySQL does string concatenation differently from other databases, so in case you want to port your app, you need to have an alternate version where || is used as concatenation operator, as mentioned by Michael in another answer. This operator doesn’t … Read more

Categories mysql Tags join, mysql, sql-like Leave a comment
Older posts
Newer posts
← Previous Page1 Page2 Page3 Page4 … Page7 Next →

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa