Questions tagged as 'mysql'

1
answer

Select the first row of each group in MySQL

Suppose I have a table like this: item | group -------+-------- item a | group x item b | group y item c | group y item d | group x item e | group z And I want to select a single item to represent each group. Now, you should be thinkin...
asked by 27.08.2018 / 04:03
1
answer

How to join 2 SQL queries into a single one (one is an average value calculation and another search criteria with BETWEEN

I am setting up a system that finds providers in a specific region, calculates the average amount charged by them and brings this value. But before that he will only pick up the providers that are available on the requested date. I have these...
asked by 03.08.2017 / 15:32
3
answers

How to solve foreign key error 150 in migration with laravel?

I'm having trouble creating the foreign key in migration. I'm working with PHP, LARAVEL 5.3 and MYSQL. You are giving me the following error: Below is my code: Table Migration of the categs class CreateCategsTable extends Migr...
asked by 28.07.2017 / 12:49
2
answers

How to generate multiple columns in a query from just one column?

I need a Query that returns 2 columns added (input and output) from the "accounting" column of the "tbl_sef" table. The value of the "accounting" column will be in the "input" column when the "cfop" column is less than 5000. And it will be in th...
asked by 16.08.2017 / 18:47
1
answer

Primary key return of an INSERT

I have tabela_x , where the first field ( campo1 ) is primary key and autoincrement . I make a simple INSERT : $ins = " INSERT INTO tabela_x ('campo2','campo3','campo4') VALUES ($c2, $c3, $c4) "; $con -> qu...
asked by 09.04.2018 / 14:16
2
answers

How to save images to the database using spring boot?

I'm having trouble saving images to a form. Does anyone know how to save image to mysql database using spring boot? I am now learning this technology, so with this difficulty. Form html:                           Providers             Suppli...
asked by 07.06.2018 / 13:27
2
answers

Generate random number for an array

I have a foreach that fetches the data from one table and makes a insert in another table. I need to count the number of foreach registers, and then generate a random sequence, and feed a insert field. See the code...
asked by 18.10.2016 / 14:24
2
answers

How to create XML tags from the column names of a mysql database?

How do I create XML tags with the column names of a table from a myslq query? In the code I made I just get the values from each cell in the table, but what I wanted was to automatically create the tags according to each column. My Curren...
asked by 13.10.2016 / 17:01
1
answer

Is there any risk in using mysqli_insert_id?

Let's suppose a website with a relatively high flow rate. A user X inserts a record into the database at the same time as another user Y inserts another record. Considering that the procedure of this insertion of user data X and user Y is:...
asked by 09.07.2016 / 18:25
2
answers

Foreign Key does not respect referential integrity

I'm trying to join tables and add a chave estrangeira , so that for example, a purchase table has referência of id of the buyers table. I did as follows: alter table compras add foreign key (compradores_id) references co...
asked by 15.12.2016 / 13:24