Questions tagged as 'sql'

2
answers

How to change the last 100 records of the table in the PostgreSQL database?

I need to change a table field in my database to perform some tests, and would like to update only the last 100 records in the table. I already tried this code: UPDATE titulo SET autorizado='S' ORDER BY id_titulo DESC LIMIT 100; More this...
asked by 02.06.2016 / 14:56
1
answer

Size occupied on disk by a table in SQLite

In Oracle, when we want to know how much a table occupies disk we can query the dba_segments dictionary. SELECT segment_name, segment_type, bytes/1024/1024 MB FROM dba_segments WHERE segment_type='TABLE' and segment_name='<nome-tabel...
asked by 10.06.2016 / 20:40
1
answer

Remove spaces via Update

I have a field called titulo , in the noticias table. Unfortunately, due to forgetting PHP's trim command, it has several titles with space at the beginning and end of the string . How can I via SQL (MySQL) update the titles...
asked by 22.03.2016 / 16:01
2
answers

How to define "charset" of a table in SQL Server?

In MySQL to set the charset of a table we can use this way: MySQL: create table user_details (...) default character set = utf8; How can I do the same in SQL Server?     
asked by 07.04.2016 / 14:46
3
answers

Do an independent search of the order of the keywords

I have a database in which I need to search based on the keywords, regardless of the order. See the full table below: +----+-----------------------+ | id | description | +----+-----------------------+ | 1 | joão de santo cristo | |...
asked by 04.03.2017 / 06:05
1
answer

INNER JOIN with where

I have the following tables: permissoes_users id_user id_permission permissions  id  - Permission I have a session variable where I have the id di user, I need to search the table for the id and those that have the id of the user to...
asked by 19.11.2015 / 12:51
3
answers

Modify array elements

I need to create a query with the insertion of several lines. Change an array / list:    arrayOriginal = [10,20,30,40]     valueChave = 999 The return must be:    arrayNew = [(valueChave, 10), (valueChave, 20), (valueChave, 30)...
asked by 22.06.2016 / 23:21
1
answer

SQL has no results after using bind

I made this code to create databases : public function addDatabase($name, $collation) { try { $sql = "CREATE DATABASE ':name' COLLATE ':collation';"; // Prepare the query to execute $query = $th...
asked by 04.04.2015 / 15:59
3
answers

Insert values from tableB into tableA if they do not exist

Normally, when working with a insert on tableA if it is based on select of a tableB, we do something similar to this: INSERT INTO tabelaA ( column1, column2, someInt, someVarChar ) SELECT tabelaB.column1, tabelaB.column2, 8, 'so...
asked by 28.04.2015 / 15:27
3
answers

Search results for 3 table with date of last 5 days

I have the following tables: What I'm trying to do is fetch the names of users who have no records in tbl_votos and no resources in tbl_recursos in the last 5 days . I'm using php and mysql.     
asked by 08.05.2015 / 15:08