Skip to content

Tag: mysql

Select longest word from a string SQL

Let’s say that I have a table with 2 columns: name and number. Name is a string which can have one or more words and I would like a new query with select name number but that in the name column it only has the longest word of the original table. Is there a function in SQL that extracts from

how to make cohort analysis in mysql

I have a table called order_star_member: DB Fiddle I want to find users in the month March with transaction >= 700000 and first transaction >= 700000. The user whose transaction is >= 700000 is called star member. My query so far: Explanation: in march 2021, there’s only one ‘star member&…

MySQL Java prepared statement Syntax error

I need to select rows from mysql table based on various criteria, for example Colour= Black, or size= L. The code works without the preparedstatement and the question marks, but whenever I attempt to use the question marks the code does not run. I have read something about typing the question mark like &#8216…

Unexpected result in WHERE clause on AI ID field

I have a table which’s name is users in my MySQL database, and I am using this DB with Ruby on Rails application with ORM structure for years. The table has id field and this field is configured as AI (auto-increment), BIGINT. Example of my users table; The problem I am facing is when I execute the foll…