Skip to content
Advertisement

Tag: sql

Querying an SQL result grouped by month

I have been learning PHP and SQL but have a question. I want to count the data where the year is 2019 but then want to populate a JSON array for each month. I have started by creating the following SQL and PHP code: I do not however know how to run a further query on this result to retrieve

shopping cart with PHP and connected to the MySQL

Good evening, I am currently working on the implementation of a shopping cart through PHP and MySQL, I am getting the following error at line 172 onwards, I have been looking at the quotes but I cannot find the problem, what could be the solution to this? I have been changing this cart from a mysqli version of it into

foreach array wise multi SQL query not working in PHP

I am trying to execute multiple queries with the multiple selected checkbox value-wise in PHP. I am facing trouble that my code is executing only one checkbox value-wise query and the rest is denied. I checked on StackOverflow about this issue and I got lots of threads about foreach loop but in my case, it is not working when I

Delete big chunk of data with where clause gives time-out

I’m trying to delete over 2 millions records with this statement And I get 504 error time-out, when I try the same statement with select instead of delete it works, there is an index on event_tstamp column. Any idea what could be the problem? Answer delete is a much more expensive operation than select. The deletes have to be logged,

Insert a php string as multiple rows on MySQL table

I have a table with more than 750 rows of data that I paste on a textarea and get as a single string variable, then I pass the data as just one string thru an ajax and I want to insert it on my database in just one INSER INTO line Is there a way to make this work, I

Leads to HTTP ERROR 500 PHP and SQL and i canĀ“t solve it

I m trying to show on a page {“status”:1} but instead it gives an error 500. All my code it seems to be working on database and on the plataform. It gives this errors on error log: [error] 42094#0: *233568 FastCGI sent in stderr: “PHP message: PHP Notice: Undefined index: id in /var/www/…/…/…/…/classes/pageuser.class.php on line 519 PHP message: PHP Fatal

SQL – Get multiple values when limit 1

If I have a table like this: And use this query: SELECT ident,COUNT(*) FROM sales WHERE status=? AND team=? AND DATE(date) = DATE(NOW() – INTERVAL 1 DAY) GROUP BY ident order by COUNT(*) DESC LIMIT 1 I get the value: cucu1, since that has the most rows. But if my table is like this: It should return both cucu1 and

How to insert data from one table to another in laravel?

I have two tables, visitors and in. visitors contains columns, Name, Number, Purpose, and Datetime. in contains Name, Number, and InTime. I want to fetch all the values from the visitors table into in. I have tried copying the data from visitors to in, however, if I add new rows into the visitors table, those new rows won’t be reflected

Advertisement