1
我有以下2的Python代碼:這些查詢中的%%和%是什麼意思?
def direct_by_node(self, node, partition_size):
return '''select req.id, req.profile_id as profile
from table1 attr
where id % {0} = {1}'''.format(partition_size, node)
然後
def find_by_node(self, node, partition_size):
return '''select req.id, req.profile_id as profile
from table1 attr
where id %% {0} = {1}'''.format(partition_size, node)
我想知道什麼%和%%在2個MySQL查詢是什麼?
編輯:
當我嘗試%%的MySQL工作臺,看起來像我有一個語法錯誤,看起來像%%是無效的。
https://stackoverflow.com/a/8616880/8106112 –
感謝@darnell,我已經看到了這一個,但我不完全確定它是相同的,因爲它是像「%lastuser%」之類的東西。 .. –
不要使用Python字符串格式來生成SQL查詢字符串;使用你的圖書館的能力來創建參數化查詢。 – chepner