Questions tagged [mysql++]

175221 questions
1

votes
1

answer
253

Views

How fetch_assoc know that you want the next row from the table?

If we would have code like this: $result = $conn->query('SELECT username FROM users'); $row1 = $result->fetch_assoc(); echo $row1['username'], ''; $row2 = $result->fetch_assoc(); echo $row2['username'], ''; Second echo would show username from second row in table, but why? How fetch_assoc() know tha...
Remniscate
-1

votes
1

answer
16

Views

MYSQL: How to use Multiple OR on WHERE Clause?

I am having a problem with my MYSQL statement Warning : mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in C:\Users\R.B.Lara\Documents\My Projects\focalnews\index.php on line 188 $sqltype = 'SELECT * FROM focalnews_items ORDER BY datime ASC limit $last,20 WHERE (likes >= 5 OR...
Christian Read
1

votes
4

answer
31

Views

PHP - Having trouble inserting dates from a date column with null values. Values are inside an array

I'm making a SQL Server to MySQL program that allows me to sync contents between two identical tables. However, I'm having trouble with inserting date values from a date column that has some of its cells set to NULL. The way this should work is that it should convert each value from the date column...
YMSmash
1

votes
2

answer
455

Views

Call to a member function addEagerConstraints() on float LARAVEL

My objective is to get average review of the courses available. But when i am trying to get the average review of the course its throwing me an error saying 'message': 'Call to a member function addEagerConstraints() on float' My Course Model public function rating(){ return $this->hasMany(Rating::c...
user7747472
1

votes
1

answer
296

Views

How can I find whole words only in a LIKE query Laravel?

How can I find whole words in a LIKE query in Laravel's Eloquent? For example, if someone searched SA the following results can come up with LIKE %sa%: My name is Sam I live in SA But I need a search that only returns: I live in SA How can I accomplish this while at the same time preventing SQL inje...
Oliver Kucharzewski
1

votes
2

answer
176

Views

Perform any operation in Mysql once it is launched by Terraform. How can I run provisioner for RDS?

I have launched an RDS instance using terraform, now I want to create a user and DB inside it, basically, run some query inside it. So how can we achieve that? Thanks
Nikit Swaraj
1

votes
3

answer
453

Views

MySql doesn't accepting boolean as its column datatype

I have a Java program which stores data in MySQL database in two states. For this purpose I wanted to use BOOLEAN. But whenever I enter BOOLEAN it's getting changed into TINYINT. Is there any other way to store data in two states?
pritam parab
1

votes
3

answer
442

Views

How do I escape % in Knex where like query?

I'm using knex to generate my SQL queries. In knex documentation, it shows this knex('users').where('columnName', 'like', '%rowlikeme%') Now in my application, I did this: function search(term) { term = '%' + term + '%'; knex('table').where('description', 'like', term); // ... } How can I escape % s...
Jun
1

votes
3

answer
610

Views

how to implode array of values for sql in clause?

I have an array of fruits. I am trying to get all rows that contains any of these three fruits in the column 'fruits' $fruits = array('apple','banana','orange'); $imploded_fruits = implode(',',$fruits); $sql = 'SELECT * FROM market WHERE fruits IN ('$imploded_fruits');'; this is not returning expec...
codec
1

votes
1

answer
226

Views

oop php what is the best practice for database access? [closed]

I code as a hobby so i do not have a formal education on this topic so please excuse me for this question. I really have done a lot of research on this topic but wasnt able to get a clear answer. what class structure should i choose for database acess in php? class DatabaseObject and one child class...
J. Doe
1

votes
3

answer
43

Views

mysql copy schema without data

using phpmyadmin and mysql i am trying to run the following query without success create TABLE 'amazonUK-crawler' like 'amazonDE-crawler'; 2 errors were found during analysis. An opening bracket was expected. (near 'like' at position 32) At least one column definition was expected. (near ' ' at posi...
Yossi Bondasd
1

votes
2

answer
27

Views

Getting Duplicates from two columns in different tables

I have been looking at this all day. I am trying to return a list of duplicates from two columns in two separate tables. In MYSQL the only way to get a full outer join seems to be with a UNION, which I have tried: select mobile from firstTable group by mobile having count(mobile) > 1 union all selec...
mcaidans
0

votes
0

answer
15

Views

How to search values using flexible search query?

I need to pass the below in a query suppose : 1,2,3(to be compared with column A) & 589,123,789,896(to be compared with column B) & check if there are available in the below table or not? Is it possible Flexible search quey or SQL Query? Below Table : ABC A B 1 123 1 456 1 789 2 568 2 8...
User2413
0

votes
1

answer
13

Views

How to create a script that can migrate database to another normalized database

I have an existing system with hundred thousands of data. I need to migrate it to another database but different structure. How can i create a script that will migrate database to a different structure. I tried csv but i need to make some columns to foreign key because the new database is much norma...
0

votes
1

answer
11

Views

Optimizing SSIS package for millions of rows with Order by / sort in SQL command and Merge Join for millions of rows

Hi i am currently trying to optimize an SSIS package when i do an Upsert/delete which handels about 93+ million rows from a table in a remote MariaDB source. The table also contains approximately 63 columns. Currently i'm using Sort and Merge Join in my package but as i've read some guides its recom...
John
0

votes
0

answer
13

Views

SQL Database - Taking one columns max value for another table column

I design my database and have 3 tables: 1) Authors table has ID, Name, Surname, and Paper_ID. Name and Surname combination is unique. 2) Topics table has TopicName, SOTAResult, and Paper_ID. TopicName, SOTAResult are unique. 3) Papers table has Title(unique), Result, Abstract. I design it like that...
volkan yılmaz
0

votes
0

answer
9

Views

is calculated table possible?

Is it a good idea to create a calculated table which contains the results of complex calculation? For examples, the calculation involves regression and prediction etc. As the results will be used in future analysis frequently, I prefer doing the calculation once when new data come in instead of calc...
Hawii Hawii
1

votes
2

answer
57

Views

How to make the mysql query using group by

Below is the table structure I have user_id quote_id bill_type(2=>proforma,1=>invoice) 474 676 2 674 676 2 474 676 1 445 680 2 422 120 2 411 240 2 411 240 2 410 240 2...
Nikhil Gupta
1

votes
2

answer
77

Views

Python MySQLdb file load truncating rows, works fine when loading file from another mysql client

I'm getting data loss when doing a csv import using the Python MySQLdb module. The crazy thing is that I can load the exact same csv using other MySQL clients and it works fine. It works perfectly fine when running the exact same command with the exact same csv from sequel pro mysql client It work...
emmdee
1

votes
1

answer
37

Views

Deleting a django model class object without foreignkey warning

I have two tables in MySql created with django models.One is Students model, other is Attendance model. class Attendance(BaseModel): stu = models.ForeignKey(Students, verbose_name=_('Student')) I did't put 'on_delete=models.PROTECT' to stu in Attendance class, because i need to able to delete a Stud...
ivbtar
1

votes
2

answer
81

Views

How to write replace string function inside Yii2 query

I have a MySQL query which selects column based on the replace string values passed to a column SELECT * FROM Table WHERE REPLACE(column_name, '.', '') = 'value'; In the above query i remove dot values from the column_name of the table and I pass values with out dots and it works fine. Now i need t...
ManoharSingh
0

votes
0

answer
6

Views

Turbogears2 with MySQL db not update tables in multi threads

I am using turbogears2 with MySQL db. With the same code, single thread case can update/write to the tables. But thread thread has no error, however, no write is successful. Outside turbogears2, multi threads can write to the tables no problems. No error or complaints with multi thread with tg2. Ju...
Simon Wu
1

votes
2

answer
25

Views

if less than 0(negative) days , appear EXPIRED

Things that i want to achieved: if less than 0(negative) days , appear EXPIRED What should i do if i wanted to show less than 0(negative) it will show expired instead of showing -1 ? http://prntscr.com/mip2tc , < this is the output i know that stackoverflow is not a answer platform , but i have no...
BlueMoutain
1

votes
1

answer
46

Views

“Packet for query is too large” error. Where to change max_allowed_packet variable?

I am having a problem, I imported a spring boot project from git, the code is working perfectly fine in my teammates computers, but I get an error That I don't know how to solve, while running my java application I get this error : Packet for query is too large (1072729 > 1048576). You can change th...
Taoufiq Benallah
1

votes
1

answer
34

Views

Issues with “MySQL 8” sql statements

I updated to mysql 8 I face issues with creating of the accounts table. CREATE TABLE IF NOT EXISTS accounts( id INT(6) UNSIGNED AUTO_INCREMENT UNIQUE, username VARCHAR(30), email VARCHAR(100), password VARCHAR(255), rank VARCHAR(10), ban VARCHAR(10), token VARCHAR(100), created_at VARCHAR(100), las...
Tutorialwork
1

votes
1

answer
27

Views

Get Storing updated rows and previous rows as well

Let's suppose I have table as : column_1 | column_2 | column_3 | column_4 abc 12 23 34 abc 01 12 45 I am looking for query something like insert into table(column_1,column_2,column_3,column_4) values(List of updated rows i.e select (do some logic here...
Dhanraj
1

votes
5

answer
43

Views

SQL Query Using Joining Tables, Group By, and Where

Question: Which orders have a value greater than $5,000? Query I am currently using: SELECT o.orderNumber, o.orderDate, d.quantityOrdered*d.priceEach AS totalAmt FROM orderdetails d, orders o, products p WHERE p.productCode = d.productCode AND d.orderNumber = o.orderNumber; Output Looks Like: '101...
doublepancake84
1

votes
3

answer
46

Views

group by year on multiple date columns mysql

I have table as following: hours | ... | task_assigned | task_deadline | task_completion ---------------------------------------------------------------- 123 | ... | 2019-08-01 | - | - 234 | ... | - | 2018-08-01 | 2019-08-01 145 | ... | 2017-08-01 |...
Azima
1

votes
2

answer
24

Views

how to export all databases as separate sql files instead of localhost.sql

I want to export all databases as separate .sql files but I get localhost.sql Can anyone here show me how we can accomplish this?
Lawrence Bosumbe
1

votes
2

answer
42

Views

Laravel: How do I access the unique ID of a logged in user and use it in a database query?

I am making a website for college administration where professors log in and assign marks to the students they are teaching. There's a table, called 'IA_Marks' in my database: |Student_ID|Subject_Code|Name|Marks1|Marks2|Marks3|Semester|Division| There's also a table called 'Classroom_Mapper' in my d...
1

votes
2

answer
35

Views

How to count rows grouped by an attribute, where that attribute has not appeared before a specific date?

Assume table Orders CREATE TABLE Orders ( order_id int(11), customer_id int(11), purchase_date datetime ) We need the following report: For customers who did not place an order prior to this month, how many orders were placed per customer? Here is the very slow sql that I am currently using: SELECT...
Blam
1

votes
3

answer
32

Views

SQL Get Users By One Group But Exclude Others

I'm trying to write a query that retrieves all users that belong to group A, but excludes users that belong groups B, C & D. Users are uniquely identified by user_id in the users table, but can have multiple entries in the groups table. I have the following query but it's not working: SELECT user_id...
Dangerman1988
1

votes
1

answer
30

Views

Remove MySql database table on remote server from C# application

If I can create MySql database table on remote server from C# desktop application string createTableQuery = string.Format(table, tableName); and var cmd = new MySql.Data.MySqlClient.MySqlCommand(createTableQuery, conn); Then how do I remove table from MySql database by tableName Any guide, advice o...
viktor80
1

votes
2

answer
40

Views

When Delete button hit, image needs to be deleted from table, error message showing instead

I have a gallery where I want the user to be able to update the image title and delete the image if they wish. My update the title code works as expected, and I assumed the delete code wouldn't be far off the same.
qwpozxmn
1

votes
1

answer
43

Views

mysql procedure for insert with select from another table

I want to create a procedure that creates a course for a user this takes one parameter that is userid and the other value will be selected from tbl_chapter.there are 27 chapters that are going to be selected and 27 inserts will be executed .insert is going to be like INSERT INTO tbl_user_chapter(use...
H.sanati
1

votes
2

answer
30

Views

MySQL returns wrong results with the BETWEEN clause

I am using the following query to get data from mysql database and I get wrong data. I want to show release_year from 1990 ~2000, but it's showing me everything. SELECT title,release_year FROM FILMS WHERE release_year BETWEEN 1990 AND 2000 AND budget > 1000000000 AND language ='Spanish' OR language...
LenaLD
1

votes
1

answer
28

Views

How to get a constant value back in SQL

I have a SQL query that fetches 50million records . I want to assign a constant value to each row in the results which should be different everytime I run the query. So I decided to use system date in the query. My query looks like : SELECT (SYSDATE,'DD-MM-YYYY - HH:MM:SS'), column1,column2,column3...
jaideep singh
1

votes
1

answer
83

Views

EF Core with Mysql not scaffolding BIT(1) to Boolean

I am trying to generate DB classes from the existing database (DB first) through. Net core CLI. The DB was perfectly working with EF5 and .net4.5 but after migrate to EF core the bit(1) field is not scaffolding as bool instead it is generating as short. Also tried with TinyInt(1) but no luck. Techno...
ni3.net
1

votes
1

answer
32

Views

NodeJs create new array from MySQL query result

In my NodeJs project i want to create new array form MySQL query result. This is my result: [ { 'availabilityId': 1, 'dayName': 1, 'fromTime': '05:30:00', 'toTime': '10:00:00' }, { 'availabilityId': 2, 'dayName': 1, 'fromTime': '10:30:00', 'toTime': '06:00:00' }, { 'availabilityId': 3, 'dayName': 2,...
Ramesh S
1

votes
2

answer
79

Views

How to retrieve data from one table based on the calculation of another two table?

Suppose I have Three model named as Customer ,Invoice and Payment. Invoice and Payment model looks like id , customer_id, amount I want to get only those customer whose Invoice.sum(amount)>Payment.sum(amount) with these amount difference I am currently retrieve like $customers=Customer::get();...
Helal Uddin

View additional questions