Skip to content
Advertisement

Select from two tables by unique Id [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 13 days ago. Improve this question I have two tables calendar and team, to simplify : in calendar table i have Id, team_id1, team_id2 and date, and in team table i

strapi with mysql running simple raw sql

Need to run this query in my test and unable to find the right syntax. This is no postgresql and mysql does not like hyphens in table names. Please suggest. Answer Simply don’t use not allowed characters, it makes the life much more easy. The backticks around the String, where implemented, so that theuser dind’t need to escapee single and

SQL query optimization for speed

So I was working on the problem of optimizing the following query I have already optimized this to the fullest from my side can this be further optimized? Answer Your query although joined ok, is an overall bloat. You are using the dim_ad_type table on the outside, just to make sure it exists on the inside as well. You have

How to get the average from multiple columns

I saw this answer how do I select AVG of multiple columns on a single row but I have some rows which is the value is 0 and it’s throwing an error division by zero when I try to use his ex. Answer In order to resolve the task, you can use CASE expression because you cannot divide by zero:

convert multiple date format into one format

I would like to know the answer I have this kind of problem, I have one column that consist 2 date format but in string format and then I would like to convert it to default datetime format, so it would be like this I’ve tried many ways but cant find the solution, Answer Consider below query query results

How to allow a gender field to accept only two values?

The question: Add a gender field. Ensure the field will only accept ‘M’ or ‘F’ and the default value should be ‘F’ PostgresSQL code: ERROR: syntax error at or near “Check” LINE 2: add Gender varchar(1) default ‘F’ ,Check (Gender = ‘M’ or G… How do i fix it? Answer Your approach is good, there is only a small syntax

Query using a column which contains the value of another column

I have the following table in SQL Server 2019 Note: ManagerUserID is nothing but the userid The data is How can we get user details and their manager details (they are just another user) by using one query? These are my scripts Answer You can use a subquery or a self JOIN to achieve this: Result: Optionally, you can add

How to select a nested item of json datatype?

I have a MySQL table named computers with a column named details that is json data type formatted. I’ve inserted a value like this in that column: I can simple get Chrome value by the following query: Now I want to know, how can I get 1680 value (which is the value of x) ? Answer You can alter your

Advertisement