I have a nativeQuery in my DAO layer inside my Spring Boot app. Basically, I’ passing three parameters, like so: I would like to have different WHERE statements executing depending on value of companyName, something like this: Or Answer Use boolean logic:
Tag: mysql
Orderby on multiple columns using typeorm
In my application, I am using MySQL and typeorm and want to do orderBy using multiple columns. I searched so many places for it but did not get any solution. Example: I have two columns in a table user and respective User Entity ________________________________________ | id | name | createDate | createdTime |…
How to make a query that may combine COUNT(*) from one and some attributes from the other one
I’m starting to learn some SQL and at the moment I’m having some issues making a query. I have two tables: coursetbl: This table has a courseSectionNum, StudentID, courseID, classroom, meetDays, sitNum, beginTime, endTime. I’m interested in courseSectionNum, classroom, meetDays, and both the…
Mysql comma seperated to json-array
I have some fields in the database that are comma selerated, something like: a,b,c,d,e and I want to convert them into: I know how to do it in nodejs / any other language, but I need to do it directly on the mysql Possible? Thanks Answer The simplest approach probably is to use string functions only: Basicall…
find exact number in text field in sql
I am trying to query exact number in array inside text field in sql so for example can return which is not good because i would like to get the arrays that contain 1 Answer You could use JSON functions:
MySQL: Join three tables, comparing two values
First of all, I’m an amateur on SQL. Here it is the example. From this three tables I would like to know who are the teachers that make more money than Mike Table1: Table2: Table3: So far I’ve made this: And I don’t know how to keep going because when I run it, an error appears. My expected …
How to update rows with new values for groups found and make this as fast as posible?
I have a table which have these fields: id, client_id, visit_id, number_of_visit. This table can have from 30k to 100+k rows of data. The primary key is client_id and visit_id. (I cannot have a row with these two values being the same, but meanwhile client_id can appear more than 1 time having different visit…
MySql : how to join this two tables with multiple pivot
I want to get the last activity of my client but i dont know how to that that with two tables that have more than one pivot. Please look at to the example below : I want this result (last activity is the lastest date of (check_mo and check_pa). and relationship between tables is (account.id => product.chec…
I want to join two tables, removing duplicate values
I have to say I’m an amateur on MySQL, plus english is not my mother’s language. Here is my first table “Teacher”: And here my second table “Course”: I would like to know which country has more teachers giving courses, but I don’t want that it count the same teacher t…
i need a query to update column transferred_to to ‘Invalid_destination’ in Storage table if transferred_to column is equal 100
the query that i tried is this But i got this output so this is my table Answer You seem to want: Note that storage is a language keyword in MySQL, hence a poor choice for a column name. It would be simpler to use another column name, otherwise you need to quote it.