Answer the question
In order to leave comments, you need to log in
How to output related mysql values?
Good day everyone. I am engaged in various types of layout, js, etc., but then at the social security office they offered to complete the task, and I'm stupid. Well, something like this.
From the elementary I can’t understand how to link the tables (I don’t know which direction to dig in mysql) such a query so that there are tables: project (id, name), task (id, name, project_id), user (name, id, project_id ). I do authorization and, accordingly, it is necessary so that when I log in, the following is displayed: project and tasks bound by project_id to the user and project. What to read? Where to dig?
(i.e. a user logged in with project_id=10, I get prject c id 10 and tasks with prject_id=10)
Answer the question
In order to leave comments, you need to log in
Two options:
1. save directly in the browser, in localStorage
Disadvantages: it will be impossible to see this list by logging in from another device or through another browser.
2. save on the server. To the database.
Disadvantages: you have to learn what databases are and how to use them.
Vue alone won't be enough.
LocalStorage
But my advice to you is to learn how to work with nodejs/express and some database like Mongo or MySQL. It's not difficult at all, but will give you 100 extra points if you want to become a developer.
Dig towards JOIN .
Get information about the project simultaneously with the user
SELECT
`user`.*,
`project`.`name` as 'project_name'
FROM
`user`
JOIN `project` ON (`project`.`id`=`user`.`project_id`)
WHERE
`user_id`='1' -- здесь подставить правильный id
SELECT
`task`.*
FROM
`task`
WHERE
`project_id`='1' -- здесь подставить правильный project_id, полученный в предыдущем запросе.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question