11. september 2016 - 21:18Der er
12 kommentarer og 1 løsning
Trække data ud fra to tabeller i en database.
Jeg har en MS database .mdb hvor i der er to tabeller. Jeg skal trække alle data ud af begge tabeller, men der skal sorteres efter (ORDER BY) et felt kun i den ene. Jeg laver det hele i Classic ASP og VBScript.
NOGET MED: select * from A select * from B ORDER BY cpr i tabel B
Hi and thanks for the answer. It works but not ok. The tables are not the same, and not same number of columns. The columns must also have similar data types and mine are not. Also, the columns in each SELECT statement must be in the same order, and its not.
I only want to get data from table1 but ORDER BYa colume in table 2.
"I only want to get data from table1 but ORDER BY a column in table 2"
In your original question you said you wanted ALL the date from both tables but now your saying you only want data from table 1
Can you give an example of your tables and data and also what you expect to see in the result. Your also welcome to send an example to me ekspertenATsanthell.dk AT = @
Tables are the same except (Måned) (År) (Side_Hits) are different in both Tables.. Want all data from Table1 out listet, but ORDER BY (Side_Hits) in Table 2.
OK, and I assume that Side_navn in table 1 is unique?
You need to make a query. Add both tables to query then using mouse drag Side_navn from table 1 to Side_navn in table 2.
Then add the fields from both tables which you want to see in the query. You do that by clicking on each of the fields. Now you need to choose Side_hits from table 2 as sort order.
Save the query and then if you right click in the query designer where tables are shown you can choose SQL view. This is the sql you can use in ASP but you can also select from the query
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.