okay guys, this is a big one that’s confusing as hell. I’m creating a forum type dealio: I have an array of Topics and each topic has an array of Posts associated with the Topic. The Topics list page should show the latest Post from that specific Topic. (Each topic is in a category as well) Topic Latest post …
How to update row by id using case?
Is it possible to update by id other row values? I try like this But nothig.. UPDATE era SET id = CASE WHEN id = 3 THEN gender = ‘Female’–or maybe it is possible to call insert command here? …
can i use md5 hashed values inside $this->db->escape() in codeigniter,
when i tried to use md5 hashed values inside $this->db->escape() i’m getting error like below when i tried to fetch count of results “Call to a member function num_rows() on bool” my code Answer You are making double escape as i see it. Remove the single quotes from $this->db->es…
get users that did not buy a product
I have three tables users table +————————–+————–+——+—–+———+—————-+ | Field | Type | Null | Key | Default | Extra | …
Are SQL Server unique constraints “Silent” or do they raise an exception?
I want to prevent inserting duplicate values into my tables. At first, I added code to check if the value already existed in the database, but that seems like a lot of overhead / wasted time if I can prevent it at the DDL level. So I found this and changed one of my tables (as an example) from this:
Update query without condition but need to update 90% of records in a table – SQL / SnowFlake
Update query without a condition but need to update a certain percentage of rows in the table for a specific column. Say I have 100 rows in a table, I want update a specific column based but no specific condition; just that 90% of the records in the table has to have this new value that I want to update.
Is there a way to dynamically execute queries in SQL without using user defined function?
I am currently working on the table containing some documents data, focusing on the columns containing date of document and net income. What I have to do is to write an sql statement which will result …
PostgreSQL cross join using max returns null
I want to select the max() value of the modified_at column in each of several tables: This works correctly as long as each of the tables has at least 1 row. The problem is that when just one of the tables has 0 rows, null is returned for all tables: What is a solution that returns the correct values for
How to run a unique function to calculate and replace a null value in a database?
In the above database, I want to calculate the value for “A2” using the other 3 variables. The premise is that each column has a specific score with respect to each variable and the javascript would sum the answers in a row with a null blank in the A2 slot in this case. Answer You can implement th…
Limit MYSQL search results to dates greater than variable
I have a MYSQL table posts which contains a VARCHAR(25) column created that is filled with datetimes in the format XXXX-XX XX:XX:XX. I’m attempting to search by dates > now – 24 hours. When searching with just one posts.uuid I get the desired result, which lists all posts from that uuid that ar…