Questions tagged as 'sql'

3
answers

What is the meaning of the symbol || '-' || in SQL

I'm doing a query in an Oracle database and I come across this || '-' || symbology in my query . Would you like to know the meaning? Select xf0cdloc || '-' || XN4CDEMP AS LOCOMOTIVA, From Trem     
asked by 31.01.2017 / 14:07
4
answers

Performance of COUNT (*) and COUNT (1)

What is the difference between COUNT(1) and COUNT(*) in an SQL query. For example: SELECT COUNT(1) FROM USUARIOS; and SELECT COUNT(*) FROM USUARIOS; Is there any difference in interactions within SBGD? Which would...
asked by 20.06.2017 / 19:41
1
answer

SQL LIMIT parametrized in PHP with PDO

A few days ago, I stopped using the mysql_* functions (because they are already obsolete), and switched to PDO . I have a function that does query the database, but I'm having some problems using LIMIT with prepared statem...
asked by 23.02.2015 / 16:00
2
answers

=, BINARY, LIKE, LIKE BINARY, REGEXP, SQL binary collation

Reformulation of the question from @GabrielHenrique's answer and search: What is binary collation in a string column in the table? BINARY serves to make a case-sensitive search and LIKE case-insensitive, then LIKE BINARY...
asked by 03.03.2018 / 14:48
2
answers

___ ___ erkimt Error in MySQL "expects parameter 1 to be resource, boolean given in" ______ qstntxt ___
%pre%

I have this code and can not see error in it, but it gives me this error. I know there should already be a topic of this on the site but I have tried all the ways and nothing. Give me the bool error (false)

    
______ azszpr28190 ___

This error happens when %code% or %code% fails, it is usually a syntax error in the sql query and returns a %code% as explained in manual . For mysql_fetch _ * () to function properly you must pass a variable of type %code% or %code% which is the return of %code% / %code% on success.

To fix the error you can force mysql_ * mysqli _ mysqli _ to display the database error with the mysql_error () or mysqli_error ()

Version with old mysql functions _ *

%pre%

Version with mysqli_ * procedural

%pre%

Version with mysqli_ * OO

%pre%

The query will return this error because %code% is a reserved mysql word.

  

Error Code: 1064. You have an error in your SQL syntax; check the   manual that corresponds to your MySQL server version for the right   syntax to use near 'desc'

The other way is to print the query and test directly at the database:

%pre%

Related:

Why should not we use functions of type mysql_ *?

MySQL vs PDO - which is the most recommended for to use?

How to print the SQL statement being sent to the bank?

    
______ azszpr333477 ___

The problem occurs because the %code% method needs a parameter with the connection to the database.

I leave an example below. Remember to modify the data to connect to the bank.

I leave it as a hint for you to study using the PDO because it is safer and the %code% is already depreciated.

  

Example:

%pre%     
___

$query = "Select * from servico where ID_SERVICO = $id"; $result = mysql_query($query); if($row = mysql_fetch_array($result)) { $nome = $row['NOME']; if($nome == 'Marketing') { include ("servicos/marketing.php"); }...
asked by 07.08.2014 / 19:13
2
answers

What is the question mark in a query?

Does%% use of a query really prevent SQL injection ? Avoid 100%? I saw this code and I heard lots of people talking about it, saying it helps in this case and how to use it? Could someone give a better example? $query = "SELECT * FROM tabel...
asked by 26.06.2014 / 23:18
1
answer

What is the purpose of the RESTRICT, CASCADE, SET NULL, and NO ACTION options?

When I'm going to create a foreign key type relationship between two tables in MySQL, I can specify some additional options in the ON UPDATE and ON DELETE events that are associated with the change and deleting records. The options are:...
asked by 09.06.2017 / 19:16
2
answers

What is the problem of queries N + 1?

Whenever we work with some ORM, it is common to fall into the queries N + 1 problem. It's something about performance, called up to antipattern . But what is really this problem, why it happens, what are its main causes and how, in theory,...
asked by 15.06.2018 / 05:00
2
answers

How can I query for the heaviest queries in SQL Server?

In the SQL Server database, how do you know which queries have consumed most of the database resources at runtime?     
asked by 12.12.2013 / 17:31
3
answers

How to rename all tables in a MySQL database

I have a MySQL database with several tables and I'm migrating to another database.    I have a Client and must be a client PE       I have Product and must be Product_PE How can I accomplish this without however pausing to rename each of...
asked by 26.03.2015 / 04:52