forums › forums › SQLyog › Using SQLyog › Newbie Question – Point Me To Right Direction
- This topic is empty.
-
AuthorPosts
-
-
July 23, 2011 at 7:03 am #32448
peterlaursen
ParticipantYou will need to execute a SELECT … JOIN statement. Refer MySQL documentation: http://dev.mysql.com….1/en/join.html
The SQLyog Query Builder will help you to generate such. Read about it in the program help (help .. help menu).
In this simple case you can also write and execute a “JOIN in the WHERE clause” (what you may find simpler). It would be something like (I abbreviated your column names)
Code:SELECT table1.name, table2.phone FROM table1, table2 WHERE table1.id = table2.id;(I assume here that you have already selected the database – if not you can use 'fully qualified table name's like “database_name.table1.name” etc.)
Once the statement has been executed a RESULT tab will open. From here you can edit data after changing the dropdown from 'read only' to one of the tables.
-
July 23, 2011 at 7:29 pm #32449
iyog
MemberWow, very good! This is exactly what I wanted!
Now, can you tell me what is the difference between Query and View table aproach? Can I get the same with Objects/Views/Create View… ?
And one additional question – is it possible to somehow format my cells or records there in Results table? Example: to sort records with different colors according to ID 'relationship'.
-
July 24, 2011 at 7:34 am #32450
peterlaursen
Participant1)
You may create a VIEW. Just
Code:CREATE VIEW my_view AS SELECT {your current SELECT statement goes here}.. and the he VIEW (or the Query if you like) will open in the DATA tab directly, so you will not need to write the queery every time.
Or you can add the query as a 'favorite'.
2)
There are no formatting option like this. For better overviey you may add an ORDER BY clause to the query. It is actually a good idea to do as there is no guarantee in what order the server will retrun data if you don't. It could be
Code:SELECT table1.id, table1.name, table2.phone FROM table1, table2 WHERE table1.id = table2.id ORDER BY table1.id;(use ASC or DESC keyword to sort ascending or descending if you want).
-
-
AuthorPosts
- You must be logged in to reply to this topic.