I have a table containing a column authors that contains names of authors for different articles (different rows). I want to add a new column that contains a unique index for every author,i.e. let’s say 12 for every occurrence of Dickens (just a random pick) in the author column. Can it be done by a MySQL query or will I
Tag: mysql
Select row with most recent date per user
I have a table (“lms_attendance”) of users’ check-in and out times that looks like this: I’m trying to create a view of this table that would output only the most recent record per user id, while giving me the “in” or “out” value, so something like: I’m pretty close so far, but I realized that views won’t accept subquerys, which
mongoDB vs mySQL — why one is better than another in some aspects [closed]
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago.
effective innodb_lock_wait_timeout value check
I have a table with lakhs of rows. Now, suddenly I need to create a varchar column index. Also, I need to perform some operations using that column. But its giving innodb_lock_wait_timeout exceeded …
Get highest ids in by an inner join and max id
I got two tables, conversations and messages, What I’d like to do is to make a inner join from conversations to messages. Here is my query: SELECT messages.msg, messages.`read`, …
How to return rows that have the same column values in MySql
Lets consider the following table- I am a total SQL noob but how do I return the Scores featuring both IDs 2 and 4? So it should return 100 since its featured in both ID 2 and 4 Answer This is an example of a “sets-within-sets” query. I recommend aggregation with the having clause, because it is the most flexible
How to add value to SET field in mysql?
I have a table named user with a field of type SET named privs. The allowed values of this field are: ‘ADD’,’EDIT’,DELETE’,’ALL’. What SQL query should I execute to add let’s say value ‘EDIT’ to the field privs for a given row? But only if there is not already such a value. EDIT: I tried: update user set privs=concat(privs,’EDIT’) But
Converting Numbers to Words in MYSQL result! Using Query
I am trying to print a output as follows when I execute a query in mysql. Name Salary Sal_in_Words Mohan 45000 Rupees Forty Five Thousand Only The column Salary has a value 45000 and in the …
Calculating a Moving Average MySQL?
Good Day, I am using the following code to calculate the 9 Day Moving average. But it does not work because it first calculates all of the returned fields before the limit is called. In other words it will calculate all the closes before or equal to that date, and not just the last 9. So I need to calculate
Based on date range how to get unique, new, and repeat results?
I have a database table with datetime field and also contains user id (foreign key). I need to get the activity of unique, new, and repeat users. If a user does some activity, a database row is …