Would it be possible to add more rows base on Keyword string in SQL ? table A table B Example: Output of the SQL should be – How to find string with keyword ‘FamilyCare’ in PromotionName of table A base on promotion_code of table B? If it exist it will add more rows in output Any help with t…
Tag: sql
insert datetime from csv to postgres error
I have a csv file: output: And then I tried to insert the file data into postgres database: Error: It works in psql client. I thought it is the string character ‘T02’ issue,so I use: Then the error became: Then I thought I need convert it to datetime first: Same error as the last one. Then I did s…
MySql view with group_by very slow
I have two tables, appointments and clients. The tables are big, each with about 100M records. each has a primary key on id clients has a foreign key on appointment_id I’m using mysql 5.7 As one would expect, the following query is lightning fast: But, if I create the following view and query, it is int…
LEFT Join on a Subquery with specific criteria
I have two tables that I am trying to JOIN I am attempting to Select from table1 a and LEFT JOIN table2 b on a.id = b.id – however, I want to only select on the id in table2 where MAX(EndDt) Is something like that doable? Answer There are a few ways you can do this. I make some assumptions
Separate user role in SQL
I have a table called user_role_link where the column are userid, roleid, bitlive and bitdeleted. This table links to the dbo.user_role where in here I have columns roleid, DescriptionRole I want to extract all the users with introleid in (256, 308, 313) but not to be part of this roles: introleid NOT IN (225…
Which keywords did I missed on the following tables?
My problem: I get the same error on the tables: Tasks, TimeSheet, TimeSheetHour. I still don’t have any idea on what keywords did I missed. Here is the error I got in Tasks table: (same with other tables) May I know which keywords did I missed on the following tables? Answer The keyword is REFERENCES no…
How to create a Temporary table in Bigquery
I’ve been trying to build up a Temporary Table with both CREATE TEMPORARY TABLE and WITH statements in the following query. So far I couldn’t get any positive result and I don’t know what’s going on. In last line, the error alert says: “Syntax error: Expected “(” or “…
How do I search for invisible characters in a database table column?
The database table in question has a unique username column. When the usernames are listed in phpMyAdmin or SqlYog, a duplicate for at least one username appears. When the username is displayed on a web page and the HTML is inspected, it can be seen that the duplicate username is preceded by an HTML entity &a…
Three table join with matched and unmatched records
I have three tables: store article_to_store article table. I need all articles with the store name. For all articles, I want to list all stores store table contains 3 stores. article table contains 2 articles. article_to_store relation table maybe has 2 records. One article in 2 stores. I need a mysql query w…
How to check whether a user has records in past?
Sample Table Above sample table consists Users info who completed certifications. An user can also go for retraining but he/she should have completed a course before retaking it. User Id: 2 is retrained on certificate 2, he has a record in past (Completed same certificate earlier), but User id: 3 has no certi…