Method for querying database and smart card

The invention discloses a method for querying a database and a smart card. The method comprises the following steps of: determining a length value of a redundant field of each table in N tables to be connected, wherein N is more than or equal to 2; determining a connecting sequence of the N tables to be connected according to the length value of the redundant field of each table, wherein the table of which the length value of the redundant field is greater is subjected to connecting operation earlier; and performing connecting operation on the N tables to be connected according to the connecting sequence, and outputting a query result. By the invention, requirements of multi-table connecting operation on internal memory are greatly reduced, so that the operating efficiency and multi-connection success rate of the smart card are improved.