Questions tagged as 'mysql'

1
answer

Perform RANDOM SELECT [duplicate]

I have a table where I always want to display a single record in a random fashion. I'm doing this: SELECT 'id' FROM 'tabela' ORDER BY RAND() LIMIT 1 I see that in this way the same records repeat a lot, is there a better way to do it?...
asked by 18.01.2016 / 10:21
1
answer

Relate two mysql tables with data from the same column?

I'm creating a 2014 cup table. I created two tables. times (ID, nome, sigla, bandeira) jogos (ID, fase, local, time1_id, time2_id, data) I have a relatively simple problem, but I did not find a search solution ... I want to make a Selec...
asked by 10.06.2014 / 22:10
1
answer

Laravel Eloquent Relationship Performance

I realize that in Laravel 4 Framework , when we have a relationship, instead of using JOIN of Mysql in the source code of Eloquent , it uses a select. For example. I have these two Models. class Usuario extends Elo...
asked by 29.01.2015 / 16:00
3
answers

Insert line break in field text in database

I have a table with a field type text , the field stores a string string imported via file .csv , it was inserted without a line break and I'm trying to insert it, that the line break should happen after the "-", hyphen hyphen spac...
asked by 08.02.2015 / 14:17
1
answer

How to insert into a database with special characters?

I am doing the following INSERT : $result = mysql_query("INSERT INTO tbl_livro VALUES (NULL, '$titulo', '$autor_livro')"); What happens is that there are authors who have names with special characters, for example: O'Reilly Media, In...
asked by 29.01.2015 / 12:08
1
answer

Get rows that are not logged in

I have a table with columns para and de where I enter different IDs in each one, however I need to get the ID of the user that sent the request to me, ie the ID that is not the same as the user logged in. SELECT 'username' FROM a...
asked by 01.02.2015 / 23:48
3
answers

List the months, per year in mysql

I'm trying to do the following in php and mysql : What is in parentheses is the number of results within each month. For this, I am saving in my database, in the tbl_noticias table the data field of type yyyy...
asked by 24.03.2014 / 13:11
2
answers

Absolute ordering for data returned from DB

In PHP I'm doing a query to my database using MySQL. In my database I have the fotos_album table and inside I have the name of the photo. I want to sort the table by the nome field. We imagine that the table has the following da...
asked by 18.03.2014 / 12:16
2
answers

Log Lock

How can I lock a record in MySQL? For example, I have a record that is being accessed by user 000, and I want to lock this record so users other than 000 can not access it. Is it possible?     
asked by 09.07.2015 / 15:23
2
answers

Helps to make a condition in php

I have here my php code so that you can delete the client, but only delete it when you write the client name (which is in the html). but I do not know how to make the condition if someone writes a name of a client that is not in the database. An...
asked by 15.06.2015 / 00:19