G
G
godpop2015-12-18 14:21:05
MySQL
godpop, 2015-12-18 14:21:05

How to create join two tables?

Hello! Help join two tables. Already as soon as join did not try, it is impossible. There are two tables:
block
blockID
blockType
block_text
textID
blockID
name
The second table contains the blockID of the elements of the first table. How can I join two tables, if I know that blockID = 3 in the second table, and output only one blockType for this id with join? All the others are displayed all the time in a column, but one is needed.

SELECT block_text*, block.blockType FROM block_text
JOIN block_text ON block_text.blockID = block.blockID WHERE block_text.blockID = 3

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel K, 2015-12-18
@godpop

For some reason, you have a join of the same table as the select in your query,
but then you use "block"
How did such a query run at all ...
And why do you need to connect, because the connection goes by blockID
and blockID as you write, You already know that it is 3,
query then

SELECT  block.blockType FROM block WHERE block.blockID = 3

I
Ivanq, 2015-12-18
@Ivanq

SELECT block.blockID, blockType, textID from block, block_text where block.blockID = block_text.blockID

So?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question