select query in mysql

Solutions on MaxInterview for select query in mysql by the best coders in the world

showing results for - "select query in mysql"
César
17 May 2020
1$sql = "SELECT id, firstname, lastname FROM MyGuests";
2$result = $conn->query($sql);
3
4if ($result->num_rows > 0) {
5    // output data of each row
6    while($row = $result->fetch_assoc()) {
7        echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
8    }
9} else {
10    echo "0 results";
11}
12$conn->close();
Vincent
13 Jan 2017
1SELECT * FROM `table_name`;
2SELECT `col1`,`col2` FROM `table_name`;
3SELECT `col1 as name`,`col2 as email` FROM `table_name`;
4SELECT * FROM `table_name` WHERE id = '1';
Christopher
10 Jul 2017
1SELECT column_name(s) FROM table_name
Francesca
27 Mar 2018
1SELECT 
2  `nachname` , `vorname` 
3FROM testadressen
4WHERE vorname = 'Fischer'
5
Giacomo
23 May 2020
1SELECT select_list
2FROM table_name;
similar questions
queries leading to this page
select query in mysql