This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:dev:all:examples:sql-1 [27.06.2015 19:51] – [Verschiedene Beispiele für mehr oder weniger komplexe SQL-Abfragen] translated mrbaseman | en:dev:all:examples:sql-1 [27.06.2015 20:36] (current) – finished translation and removed fixme mrbaseman | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)// | ||
| ====== Proper use of SQL queries ====== | ====== Proper use of SQL queries ====== | ||
| Line 7: | Line 6: | ||
| **Attention: | **Attention: | ||
| - | ==== Abruf eines einzelnen Users ==== | + | ==== Retrieval of a single user ==== |
| - | Es wird einfach anhand der `user_id` | + | Based on the `user_id` |
| - | [color=red]falsch[/color] | + | [color=red]false[/color] |
| < | < | ||
| $query = $database-> | $query = $database-> | ||
| Line 21: | Line 20: | ||
| } | } | ||
| </ | </ | ||
| - | Dieser Code enthält gleich mehrere Problemstellen und überflüssigen Code:\\ | + | This code contains a number of problem areas and superfluous code:\\ |
| - | * Die Methode | + | |
| - | * LIMIT 1 - dieses Statement ist überflüssig, | + | |
| - | * Das SQL-Statement entspricht nicht den SQL-Strikt Regeln und ist zusätzlich noch innerhalb der Argumentenklammer von -> | + | |
| - | * WHILE - diese Schleife ist überflüssig, da ja maximal nur ein Datensatz geliefert wird. | + | |
| - | * Die Abfrage auf numRows() | + | |
| - | Nach den neuen Standards von WB korrigiert, ergibt sich dadurch folgendes | + | Corrected applying the new standards of WB, this results in the following |
| < | < | ||
| $sql = ' | $sql = ' | ||
| Line 43: | Line 42: | ||
| </ | </ | ||
| - | + | ==== Retrieve a page and to the name of the associated user ==== | |
| - | ==== Eine Seite abrufen und dazu den Namen des zugehörenden Users ==== | + | //(For simplicity, only the SQL statements are displayed.)//\\ |
| - | //(zur Vereinfachung werden nur die SQL-Statements dargestellt.)//\\ | + | To achieve this, data from two tables are required: the data from ' |
| - | Hierzu werden Daten aus zwei Tabellen benötigt: die Daten aus ' | + | It is worthwhile in any case, be read in SQL to grasp the basics. |
| - | Diese Aufgabe ist ohne jeden zusätzlichen | + | |
| - | Es lohnt sich auf jeden Fall, sich in SQL einzulesen um die Grundlagen zu begreifen. | + | |
| < | < | ||
| SELECT `wb_users`.`display_name`, | SELECT `wb_users`.`display_name`, | ||
| Line 56: | Line 53: | ||
| </ | </ | ||
| - | FIXME //... wird mit Auftauchen weiterer Beispiele kontinuierlich fortgesetzt!// | + | FIXME //...will be continued with emergence of other examples!// |