I’m trying to replace a specific piece of text. I have no experience at all with mysql. The table (content) has a column ( keywords ) containing all kind of words separated by comma. I want to replace tekst with text. Important: the whole string contains many other combined values with partly tekst in i…
Tag: mysql
mysql with date function query running slow
I found something weird while executing query today and i want to know how this happens. Below is my query: this query takes 2-5 seconds while searching for the data. Now i did small change in the query as follow: In this case query takes 2-3 minutes. Here testing_date column data in dateTime format for examp…
Select ans specific value or, if not exists, the minimum one
I’m stuck trying to solve a problem using SQL (MySQL 5.6). Need to get the address which has ID 2 or, if not exists ID 2, the lower ID. For example If a costumerID have an AddressID 2, must get that. If not, must get the minimum AddressID. The output must be like: So far I’ve tried this: but get
mysql get result from join table
I have a tables person and exam. I want to show data where all exam is PASS, show the latest exam pass_date. like table below what query to get it? please help. thanks! Answer You can use aggregation and conditional expressions: Note that for this sample data, you don’t need to bring in the person table…
How to list tables in desc order of how many times they’ve been used in MYSQL?
I need to make the script list the names of relational tables together with the total number of times each table has been used. The results must be listed in the descending order of the total number of times each one of the relational tables has been used. Here is my code so far: And here is what the ouput
How to get vowels in Like operator of SQL?
I was solving a problem on SQL from Hackerrank. I have to make a query such that it gives me all city names starting with a, e, i, o or u. I’m using Like operator but still wrong answer. Here’s the problem Link Here’s my solution- Can anybody explain? Answer LIKE does not support that partte…
MySql query to check list of ids if they are friends with me?
So I have a list of ids(userId’s) that was found using a sql command that I want to check with my friends table to see if they are indeed friends with myself, a userid I will provide with, and have a column that will represent if they are and also group them if they are my friend and not my
How to always fetch a special category item data first in Laravel
Suppose I have a table named machine with 3 columns(id, name, company). There are 5 data in that table. Here A,B,C,D,E are the machine name and XX,XY,YY are the company name. Now I want to fetch data according to company wise and there a specific company’s data will come always first. For that I use gro…
SQL query NOT EXIST very slow
I’m trying to optimize an SQL query as it is slow, and gets slower when the query result is high. There are indexes concerned fields and Tables are quite big. Answer As a starter, this condition: Should be rewritten as: This is functionally equivalent, and not using date functions on the column being fi…
Correct way to get data for BIRT reporting
We have a system which contains 4 Hierarchies. 1. Senior Manager 2. Manager 3. Supervisor 4. Employee Data related to all these are stored in different tables with respective details. There is a single address table which contains address of all these hierarchies. Sample Data Set We would be able to do a coun…