Questions tagged as 'sql'

2
answers

Set default value when creating a table in SQL

I am studying SQL Language and am having some problems in creating tables, I can not set a default value in a column, whenever I apply it indicates a syntax error. Can someone help me? I have no idea what is happening ... (If there are more erro...
asked by 01.09.2018 / 00:38
3
answers

Get last id or date inserted into a mysql table

I have a history of conversations that are registered in the table sql "conversation" and I want to pick who was the last person who inserted a message in the conversation to know if it was the user who wrote last or if it was the admin (id 28)...
asked by 24.05.2018 / 16:19
2
answers

Query in same table

I have a movement table that has the worker's record and the events related to it, I wanted a query that would return only the records that have exactly the events e1, e2 and e3, in case of the example above the records would be 001 and...
asked by 25.05.2018 / 23:21
1
answer

How to select only 1 record per month with SQL

I have a sales table and would like to select customer sales, but if the customer made more than one sale per month, I would like it to bring the older one just, how could I do that? I do not have SQL code to provide because I do not know whe...
asked by 07.05.2018 / 17:29
2
answers

Conversion from varchar to float when the string is empty and / or blank

I have a column where the strings are in the following format: " 12.05% " I need to do some calculations with these values, and I'm formatting the values that are acceptable for float / double format etc. I have the following line in my qu...
asked by 09.05.2018 / 18:28
2
answers

error: "table sales has 6 columns but 5 values were supplied"

I created the following table in sql CREATE TABLE vendas ( ID INTEGER IDENTITY(1,1), Empresa VARCHAR (20), Modelo TEXT, Preco REAL, Kilometragem REAL, Ano INTEGER, PRIMARY KEY(ID) ); I p...
asked by 18.05.2018 / 04:41
1
answer

MySQL compare a number with string returns true if string starts with number

I have the following table in the database: idUser - Username - Group 1 - John - 5GR 2 - Doe - 1GR And the following query: SELECT * FROM 'table' WHERE 'idUser' = '$name' OR 'Group = '$name' $ name is the variable that conta...
asked by 24.05.2018 / 11:18
2
answers

How to select data from a column as a column in SQL? [closed]

Is it possible to query ( SELECT ) data returned from a column such as columns ?    select questors from table; | coluna | → coluna |-------------| | dado1 | → dados retornados da consulta | dado2 |...
asked by 24.05.2018 / 00:14
1
answer

Convert .FRM to .SQL

I have a database of 300MB and I only have the FRM, MYI and MYD files. I need to convert the FRM files first to create the structure of the tables, I have already used the following tools and methods and I did not succeed: link Error: ER...
asked by 11.09.2018 / 01:17
2
answers

Date in SQL ORACLE

How do I apply a function in SQL ORACLE that just brings me records from the current month? Note: I have a date column in date format (eg 13/13/18). In the sql server I applied the function below and worked perfectly: DAT_REFERENCIA>= DA...
asked by 13.09.2018 / 19:32