Questions tagged as 'select'

2
answers

What is considered when ordering a varchar field? Being filled by numbers

I have a table with the birthdays of the month, for a reason of use here we should store this as varchar . In the use of it it is necessary to sort by the date from the most recent to the oldest, it used this command: SELECT * FROM m...
asked by 07.05.2018 / 18:41
1
answer

Query to find if value is between "1 | 3"

I have a unit table that represents the number of bedrooms of the building: id| dorm 1 | 1|3 In this case above it means that the property id 1 has units with 1 or 3 bedrooms. Then I have a search using $_GET where the dorm fie...
asked by 10.05.2018 / 16:29
2
answers

SELECT returning data that was not seen by a certain user

I'm having a hard time putting together Query I have 2 tables: video_visualizacoes with fields visualizacao_id, video_id, conta_id (This field refers to the user who viewed the video) ". videos with fields vi...
asked by 15.01.2016 / 20:01
2
answers

Sort query in an interleaved way

I'm trying to list a particular product category. example. $consulta = $pdo->prepare("SELECT * FROM msg where tema = :tema;"); $s = 'mensagens-de-aniversario'; $consulta->bindParam(":tema", $s, PDO::PARAM_STR); $consulta->execute(); w...
asked by 14.06.2015 / 20:47
3
answers

How to make a left join using a where condition?

I have two tables: category -------- id | nome | imagem user_follow_category -------------------- id | from | to | date Note: The relationship of the two tables is given by category.id and user_follow_category.to . What I w...
asked by 27.01.2015 / 10:13
1
answer

Condition in Select - SQL

I have a table where the priorities of output of the supplies per customer are stored, for example: cliente | codigosuprimento | prioridade | quantidaestoque 1 | 500 | 1 | 20 1 | 501 |...
asked by 04.10.2017 / 22:36
2
answers

Return the highest value between columns and the ID for the line of this higher value

Let's say I have two columns in my table, column A and B. +-----+-----+-----+ | ID | A | B | +-----+-----+-----+ | 1 | 500 | 681 | +-----+-----+-----+ | 2 | 980 | 101 | +-----+-----+-----+ | 3 | 110 | 981 | +-----+-----+-----+ If...
asked by 12.11.2018 / 22:28
3
answers

Problems with SELECT with 2 WHEREs

I have a somewhat amateurish problem here. I can not do this SELECT from 2 CONDITIONS, and I can not find the ERROR! Someone please give me a light there! Follow the Code: OleDbConnection Con = new OleDbConnection(); Con.ConnectionSt...
asked by 26.07.2016 / 22:53
2
answers

Select with expression "other than" with two conditions

I would like to know if there is any way to make a select using a where for a field with a parameter other than < > , with two or more items. To facilitate following example: select * from TAB_DESPESAS where cd_ite...
asked by 31.07.2017 / 22:58
2
answers

Use AND within an INNER JOIN can?

I wonder if it is possible to use AND within a INNER JOIN , eg: SELECT * FROM tab1 INNER JOIN tab2 ON tab2.id2 = tab1.id1 AND tab2.camp1 = 'valor' INNER JOIN tab3 ON tab3.id3 = tab2.id2; I gave a rather silly exa...
asked by 10.02.2017 / 14:35