I struggle to extract the required values from the JSON column in MySQL. Imagine the variable: and I need to extract and return a new JSON array containing only selected key-value pairs, eg.: only a’s and b’s and if the required key does not exist I want to return null for that key: thanks Answer …
Tag: mysql
Order by select count(*) and LIMIT is very slow
I have this query in my program, when I do some sorting with select count(*) field from the query, I dont know why, it very slow when running that query. The problem is when i do some ordering from posts_count, it run more slower than i do ordering with the other field. Here’s the query: select ‘t…
How merge these two sql queries in mysql?
I want to merge below two queries and display two p_artist.id count based on the condition of each band name but I am not getting any clue. Can anyone help me, please? Thanks Answer I mean I want to have two-column of count ids The requirements are not clear at all and I had originally typed a separate answer…
expected that this query will not output 0 values, but it does [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last month. Improve this question I expected that this query will not output 0 values, but it does. I thought that and (……
SQL query with meta_key,meta_value and have 2 conditions
I am trying to do an SQL query to find a form id of the Registration form of the user on a wordpress site, because this form doesn’t have the id of the user yet, I have to find the user email which is unique and check if the gdprchekbox-1 is true because it is only used for the registering
SQL JOIN tables and and sum columns with the same PK
Here are my tables: Players Name DoB Ranking Ben 01/01/1999 1 Tom 02/01/1999 1 Sam 03/01/1999 1 Sam 03/01/1999 2 Ranking Ranking Points 1 100 2 50 I want to join the tables and add the total points for each player then output this table. Output Name DoB Points Ben 01/01/1999 100 Tom 02/01/1999 100 Sam 03/01/1…
Optimizing select union select oracle
I had an interview recently and the recruiter told me to make a query on a table USERS with two fields (name, age) which should return a list with two columns | NAME | MAJOR OR MINOR | My response was this : Then, he told me that is correct, but we can do better! So, my question is: How
How to use LEFT JOIN and limit result to one row based on a count
Let’s say i have 3 tables: Table ‘post’ id title 0 titleA 1 titleB 2 titleC Table ‘comment’ id id_post text 0 1 blaa 1 3 blbb 2 5 blcc Table ‘like’ id id_comment vote 0 1 +1 1 5 -1 2 5 +1 I need to get a list of post with the most liked comment. The query sould
Do i need to cast integer param to string for varchar index to be used?
When i query a varchar column (indexed) against an integer number, it runs extremely slow. I thought mysql was able to infer this and cast the parameter to string, but when i use an integer for filtering it avoids the index. Is this ok? Is it a collation problem? Should i always cast manually integers to stri…
SQL Table with two relations or table with one relation and repeated rows
This is an example, the names are fictitious. On the one hand, we have suppliers who provide products to shops: Suppliers On the other hand, we have shops that sell products to consumers: Shops There are shops that have their own prices like NiceShop or ShopShop, so they don’t have suppliers. But there …