Questions tagged as 'sql'

2
answers

Best way to relate two tables

I have two tables ( groups and roles ): Table groups : +----+------+-------+------+ | id | name | color | role | +----+------+-------+------+ Table roles : +----+------+-------+-------------+ | id | name | alia...
asked by 30.04.2018 / 20:09
1
answer

Updating data in SQL

I have a table with the following fields: Nome(VARCHAR) , Email(VARCHAR) , Credito(INT) I wanted to know how, or with what command, to decrease or increase the Credito field. I know you have to use UPDATE b...
asked by 13.12.2014 / 21:10
3
answers

Table Structure / Nomenclature

I am developing a permission system and I have a universe of 9 tables, which form the final permission for the user to use my systems, however, I am in doubt about how to build two of them, that of "inherited" permissions of Systems and Groups,...
asked by 19.11.2014 / 14:33
3
answers

How to optimize SQL queries containing DELETE related to SELECT?

$a = mysql_query("SELECT * FROM catalog_items where page_id='84'") or die(mysql_error()); while ($row = mysql_fetch_array($a)){ $base_item = $row['item_ids']; mysql_query("DELETE FROM items_rooms where base_item = '".$base_item."'") or...
asked by 24.03.2015 / 06:01
1
answer

Why does binary conversion from SQL Server not return a binary value?

Why do I use the following command in SQL Server 2005 select convert(varbinary(16),N'123') returns 0x310032003300 and not 1111011 what would be the binary value?     
asked by 09.03.2015 / 14:39
1
answer

How to save user-supplied date in MySQL?

I have a form that has a field where the user's date of birth is entered, this field has a datepicker that already returns the date in year, month, day format, this date is accessed through $_GET['birthdate'] its format is strin...
asked by 07.02.2015 / 13:51
1
answer

Add value to SQL table instead of replacing

Using the following code: UPDATE 'login' SET diasvip = '".+$_POST["qntvip"]."' WHERE userid = '".$_POST["userid"]."' When I run, it replaces the diasvip with the posted value instead of adding the value to those already in the table....
asked by 07.03.2015 / 15:40
2
answers

Error while inserting - String or binary data would be truncated

When doing this insert: INSERT INTO t_cmo_oit1980_leitura(id_oit_let,id_oit,rx_num, dt_rx) SELECT (1), (SELECT id_oit FROM t_cmo_oit1980 WHERE id_oit = 6574), (SELECT rx_num FROM t_cmo_planilha_leitura WHERE id_xfc = 39517),...
asked by 19.04.2017 / 12:55
1
answer

Do select and do not return values that contain xxx

I'm doing the following select: SELECT TABLE_NAME FROM USER_TABLES ORDER BY TABLE_NAME; In this I have the name of the tables, the problem is that for each table I have a table_AUD, eg: PESSOA PESSOA_AUD DOCUMENTO DOCUMENTO_AUD I would...
asked by 11.04.2017 / 15:29
2
answers

How to list the data of a SQL query grouped by order of data presentation

I wonder if there is a way to group records in the search order. Let's say I have a table of two Local (mapped place), Time (Date and Time) fields. Place was filled in the same place then in three different times, then I have new places and back...
asked by 15.08.2016 / 21:31