For two SQL statements, do I write a judgment condition or a stored procedure?

Source: Internet
Author: User
For example, if two SQL statements, sql1 and sql2.sql2, need the result of sql1 execution, then I should $ ressql1if ($ res) {code ...}} or are these two sqls written as a stored procedure for calling? Which method is more reasonable and formal? Thank you !!! For example, there are two SQL statements: sql1 and sql2.
Sql2 requires the result after sql1 execution, then I should
$ Res = sql1
If ($ res ){

Sql2

}
Or are these two sqls written as a stored procedure for calling? Which method is more reasonable and formal? Thank you !!!

Reply content:

For example, there are two SQL statements: sql1 and sql2.
Sql2 requires the result after sql1 execution, then I should
$ Res = sql1
If ($ res ){

Sql2

}
Or are these two sqls written as a stored procedure for calling? Which method is more reasonable and formal? Thank you !!!

It doesn't matter which method to use. However, you need to unify it. You should not use a stored procedure and use the code to judge this case again, which is not easy to maintain.

This is a problem in the selection of development methods. Generally, the overall principle will be determined before system development. Whether the business logic is put in php or a database, if you choose to put it in a database, php calls a stored procedure to complete the required business operations.

If the system is relatively simple, it is easier to develop it in php.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.