很抱歉,如果这已在其他地方得到解答,但我找不到答案。
我根据我的查询使用HeidiSQL创建了一个视图。由于断电,我的查询丢失但视图已保存。有没有办法将视图转换回查询?编辑视图非常难看且难以编辑。
观点:
SELECT `c`.`assettag` AS `c_assetTag`,
`c`.`serialnumber` AS `c_serialNumber`,
`c`.`datepurchased` AS `c_datePurchased`,`c`.`status` AS `c_status`,
`c`.`dateretired` AS `c_dateRetired`,`c`.`loaner` AS `c_loaner`,
`c`.`school` AS `c_school`,`c`.`mac` AS `c_mac`,
`c`.`notes` AS `c_notes`,
`c`.`model` AS `c_model`,`c`.`location` AS `c_location`,
`c`.`lastlocationupdate` AS `c_lastLocationUpdate`,
`c`.`warrantyexpiration` AS `c_warrantyExpiration`,
`c`.`warrantyvoid` AS `c_warrantyVoid`,
`c`.`warrantyvoidnotes` AS `c_warrantyVoidNotes`,
`c`.`description` AS `c_description`,
`a`.`assignmentid` AS `a_assignmentID`,
`a`.`studentid` AS `a_studentID`,`a`.`grade` AS `a_grade`,
`a`.`gradyear` AS `a_gradYear`,`a`.`assettag` AS `a_assetTag`,
`a`.`issuedate` AS `a_issueDate`,`a`.`returndate` AS `a_returnDate`,
`a`.`school` AS `a_school`,`a`.`issuer` AS `a_issuer`,
`a`.`repossessor` AS `a_repossessor`,`a`.`loaner` AS `a_loaner`,
`a`.`backpack` AS `a_backpack`,`a`.`duckhead` AS `a_duckhead`,
`a`.`charger` AS `a_charger`,`a`.`laptop` AS `a_laptop`,
`a`.`user` AS `a_user`,
`s`.`uname` AS `s_uName`,`s`.`fname` AS `s_fName`,
`s`.`lname` AS `s_lName`,`s`.`test` AS `s_test`,
`s`.`studentid` AS `s_studentID`,`s`.`gradyear` AS `s_gradYear`,
`s`.`active` AS `s_active`,`s`.`grade` AS `s_grade`,
`s`.`tblgrade` AS `s_tblGrade`,`s`.`password` AS `s_password`,
`s`.`school` AS `s_school`,`s`.`mail` AS `s_mail`,
`s`.`lunch` AS `s_lunch`,
`s`.`dayuser` AS `s_dayuser`,
`la_laptop`.`timestamp` AS `LaptopReturnDate`,
( ( ( ( `la_laptop`.`timestamp` - `a`.`issuedate` ) / 60 ) /
60 ) / 24 ) AS `LaptopAssignmentLength`,
`la_backpack`.`timestamp` AS `BackpackReturnDate`,
`la_charger`.`timestamp` AS `ChargerReturnDate`,
`la_duckhead`.`timestamp` AS `DuckheadReturnDate`
FROM (((((((((((`computer` `c`
LEFT JOIN `assignment` `a`
ON(( `a`.`assettag` = `c`.`assettag` )))
LEFT JOIN `assignment` `a2`
ON(( ( `c`.`assettag` = `a2`.`assettag` )
AND ( ( `a`.`issuedate` < `a2`.`issuedate` )
OR ( ( `a`.`issuedate` =
`a2`.`issuedate` )
AND ( `a`.`assignmentid` <
`a2`.`assignmentid` ) ) ) )))
LEFT JOIN `log_assignment` `la_laptop`
ON(( ( `la_laptop`.`assignmentid` =
`a`.`assignmentid` )
AND ( `la_laptop`.`laptop` = 1 ) )))
LEFT JOIN `log_assignment` `la_laptop2`
ON(( ( `a`.`assignmentid` =
`la_laptop2`.`assignmentid` )
AND ( ( `la_laptop`.`timestamp` <
`la_laptop2`.`timestamp` )
OR ( ( `la_laptop`.`timestamp` =
`la_laptop2`.`timestamp` )
AND ( `la_laptop`.`logid` <
`la_laptop`.`logid` ) ) ) )))
LEFT JOIN `log_assignment` `la_backpack`
ON(( ( `la_backpack`.`assignmentid` =
`a`.`assignmentid` )
AND ( `la_backpack`.`backpack` = 1 ) )))
LEFT JOIN `log_assignment` `la_backpack2`
ON(( ( `a`.`assignmentid` =
`la_backpack2`.`assignmentid` )
AND ( ( `la_backpack`.`timestamp` <
`la_backpack2`.`timestamp` )
OR ( ( `la_backpack`.`timestamp` =
`la_backpack2`.`timestamp` )
AND ( `la_backpack`.`logid` <
`la_backpack`.`logid` ) ) ) )))
LEFT JOIN `log_assignment` `la_charger`
ON(( ( `la_charger`.`assignmentid` =
`a`.`assignmentid` )
AND ( `la_charger`.`charger` = 1 ) )))
LEFT JOIN `log_assignment` `la_charger2`
ON(( ( `a`.`assignmentid` =
`la_charger2`.`assignmentid` )
AND ( ( `la_charger`.`timestamp` <
`la_charger2`.`timestamp` )
OR ( ( `la_charger`.`timestamp` =
`la_charger2`.`timestamp` )
AND ( `la_charger`.`logid` <
`la_charger`.`logid` ) ) ) )))
LEFT JOIN `log_assignment` `la_duckhead`
ON(( ( `la_duckhead`.`assignmentid` = `a`.`assignmentid` )
AND ( `la_duckhead`.`duckhead` = 1 ) )))
LEFT JOIN `log_assignment` `la_duckhead2`
ON(( ( `a`.`assignmentid` = `la_duckhead2`.`assignmentid` )
AND ( ( `la_duckhead`.`timestamp` <
`la_duckhead2`.`timestamp` )
OR ( ( `la_duckhead`.`timestamp` =
`la_duckhead2`.`timestamp` )
AND ( `la_duckhead`.`logid` <
`la_duckhead`.`logid` ) ) ) )))
LEFT JOIN `student` `s`
ON(( `s`.`studentid` = `a`.`studentid` )))
WHERE ( ( 1 = 1 )
AND isnull(`a2`.`assignmentid`)
AND isnull(`la_laptop2`.`logid`)
AND isnull(`la_backpack2`.`logid`)
AND isnull(`la_charger2`.`logid`)
AND isnull(`la_duckhead2`.`logid`) )