求教各位大佬:
订单表( FuckOrders )的 diy_order_phoneShellID 字段,对应 商品型号表( PhonesShell )的 phoneShellID 字段。
商品型号表有一个 phoneShellDesc 商品型号描述字段。
对应的 sql 语句是
select * from diy_orders o
INNER JOIN diy_phone_shells s
on o.diy_order_phoneShellID=s.phoneShellID
where diy_order_status=2
ORDER BY o.createDateObj DESC
我想把订单表中每个订单所对应的 phoneShellDesc 字段显示到网页中。
请问上面的语句应该怎么样改呢? 谢谢指点
py 文件代码:
from flask import Flask, request, flash, url_for, redirect, render_template
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:root@127.0.0.1:3306/diy'
app.config['SECRET_KEY'] = "random string"
db = SQLAlchemy(app)
class FuckOrders(db.Model):
__tablename__ = 'diy_orders'
#id = db.Column('diy_order_id', db.Integer, primary_key = True)
diy_order_id = db.Column(db.Integer, primary_key = True)
diy_order_receiver = db.Column()
diy_order_phone = db.Column()
diy_order_province= db.Column()
diy_order_city = db.Column()
diy_order_area = db.Column()
diy_order_detail= db.Column()
diy_order_status= db.Column()
diy_order_count = db.Column()
diy_order_phoneShellID=db.Column()
diy_order_orderDealMoneyFen=db.Column()
diy_order_renderImgUrl= db.Column()
diy_order_renderImgWithShellUrl= db.Column()
createDateObj= db.Column()
diy_order_ship= db.Column()
#phoneShellDesc 这个是否需要声明?
def __init__(self, diy_order_receiver, diy_order_phone,diy_order_city, diy_order_area,diy_order_count,diy_order_detail,diy_order_status,diy_order_orderDealMoneyFen,diy_order_phoneShellID,diy_order_renderImgUrl,diy_order_renderImgWithShellUrl,createDateObj,diy_order_ship,diy_order_phoneShellDESC):
self.diy_order_receiver = diy_order_receiver
self.diy_order_phone = diy_order_phone
self.diy_order_city = diy_order_city
self.diy_order_area = diy_order_area
self.diy_order_count = diy_order_count
self.diy_order_detail= diy_order_detail
self.diy_order_status=diy_order_status
self.diy_order_phoneShellID=diy_order_phoneShellID
self.diy_order_orderDealMoneyFen=diy_order_orderDealMoneyFen
self.diy_order_renderImgUrl=diy_order_renderImgUrl
self.diy_order_renderImgWithShellUrl=diy_order_renderImgWithShellUrl
self.createDateObj=createDateObj
self.diy_order_ship=diy_order_ship
self.diy_order_phoneShellDESC=diy_order_phoneShellDESC
class PhonesShell(db.Model):
__tablename__ = 'diy_phone_shells'
id = db.Column('phoneShellKeyId', db.Integer, primary_key = True)
phoneShellID = db.Column(db.Integer)
phoneShellDesc = db.Column(db.String)
def __init__(self, phoneShellID,phoneShellDesc):
self.phoneShellID = phoneShellID
self.phoneShellDesc = phoneShellDesc
@
app.route('/')
def Show_Orders()
return render_template('Order_Lists.html',HiOrders=FuckOrders.query.outerjoin(PhonesShell, PhonesShell.phoneShellID==FuckOrders.diy_order_phoneShellID).all())
if __name__ == '__main__':
app.run(debug = True)