SHOW:
|
|
- or go back to the newest paste.
| 1 | def top_N_expensive(num_of_highest): | |
| 2 | connection = MySQLdb.connect(host='localhost', user='root', \ | |
| 3 | passwd=' ', db='inb104') | |
| 4 | cursor = connection.cursor() | |
| 5 | - | sql = "SELECT cars_for_sale.make, cars_for_sale.model, +'$'+car_details.price \ |
| 5 | + | sql = "SELECT cars_for_sale.make, cars_for_sale.model, car_details.price \ |
| 6 | FROM cars_for_sale, car_details WHERE cars_for_sale.CarId = car_details.CarId \ | |
| 7 | ORDER BY price DESC,price LIMIT " + str(num_of_highest) | |
| 8 | cursor.execute(sql) | |
| 9 | ||
| 10 | rows = cursor.fetchall() | |
| 11 | for row in rows: | |
| 12 | - | print row[0], row[1], row[2] |
| 12 | + | print row[0], row[1]+" $"+row[2] |
| 13 | ||
| 14 | cursor.close() | |
| 15 | connection.close() |