I can’t seem to troubleshoot my problem. My stored procedure: Additionally, here is my volunteer table in my MYSQL script: I am trying to insert 500 lines into this table, however error 1305 is coming up. Any help is heavily appreciated, I am quite unsure of where to go from this point. Answer This logi…
Tag: mysql
Select all the last dates from all list of id
I’m trying to select all the videos that were last inserted, without repeating any ID_video_type (id_video_tipo column). Here’s an example of the data int the database: I’m trying to run the following query but when I do that I get the following result As you can see, I managed to get the vi…
What is the query for getting user location from this database schema?
I have 4 tables – USERS, CITIES, STATES, COUNTRIES I want to select username with complete location (eg: ADAM New Delhi, Delhi, India) What is the optimal query for this? Answer Try this below script
How to prevent including database config.php from another client?
We have this config.php file: And this structure The index file is accessable via www.example.com/index.php, but the config.php file too (via www.example.com/config.php). Can others just include www.example.com/config.php in there php files and execute code with my $conn? How to prevent this? Answer It’…
Get total number of products by brand with multiple categories with PHP and MySQL
I have a query: SELECT brand FROM products WHERE brand=’”.$brand.”‘ AND category=’”.$id.”‘”.$categories_list.” The idea is to get a count of the total products within a category or across multiple categories by a category ID or IDs by a brand number. The code as…
Find all users with a unique last name
I have a table users. I wrote a sql query that displays all users with a unique last name tell my why query removes collapsed users name2 and name3? HAVING COUNT(DISTINCT u.first_name) = 1; How it works? help to understand how it works Answer The query is aggregating by last name and counting the number of us…
Count number of students above and below the average score in SQL
I have a sample table below and I am trying to get the number of student above the average score and number of students below the average score. The target result table is supposed to look like I have been able to write a query to get the names of students above the average score and this can be easily
Creating entity for database
For example, I have database with table book (id, title, themeId, authorId), table author (id, name) and table theme (id, name). I dont know, should i create entity exactly like in database (and then i will have problems with join queries): or create something like this: in second case i will have problems if…
How do I delete specific entries wherein there are duplicate entries
Sorry I’m just using this account from my old friend, he said he wanted it to have higher reputation. lol I have a table that looks like this and I want to delete the entries wherein the next duplicate ones based from the first_name, middle_name, and last_name, and alias columns. While keeping the first…
mySQL: Select rows if text column contains an item on a blacklist
I am trying to create a query that can select all posts from my database that contain a blacklisted tag unless the post contains a whitelisted tag. Tags are stored in a text column (i.e., ” tag1 tag2 tag3 “). Take for example this pseudo code: Is it possible to generate a query using the contents …