A method for querying data in cross-shard databases, comprising: receiving a query request, wherein the query request comprises a query condition, identifiers of two tables used in an association operation, and an association field; querying, according to the identifiers of the two tables used in the association operation, statistics information of respective shard databases in which the two tables used in the association operation are located; sending, according to the statistics information and the query condition, a driving table query request to a shard database in which a driving table is located, and receiving a first query result set returned by the shard database in which the driving table is located, wherein one table of the two tables used in the association operation is the driving table, the other table is a non-driving table, and the driving table is a table preferentially queried in the two tables used in the association operation; deduplicating values of the association field in the first query result set; and sending a result set delivery request and the deduplicated association field values to a shard database in which the non-driving table is located, so that the shard database in which the non-driving table is located generates temporary table data, wherein the temporary table data comprises the deduplicated association field values; sending a non-driving table query request to the shard database in which the non-driving table is located, and receiving a second query result set returned by the shard database in which the non-driving table is located, wherein the second query result set is obtained by means of querying according to the non-driving table query request and the temporary table data by the shard database in which the non-driving table is located; associating the first query result set with the second result set according to the association field, to obtain a third query result set; and returning the third query result set. receiving a query request, wherein the query request comprises a query condition, identifiers of two tables used in an association operation, and an association field; querying, according to the identifiers of the two tables used in the association operation, statistics information of respective shard databases in which the two tables used in the association operation are located; sending, according to the statistics information and the query condition, a driving table query request to a shard database in which a driving table is located, and receiving a first query result set returned by the shard database in which the driving table is located, wherein one table of the two tables used in the association operation is the driving table, the other table is a non-driving table, and the driving table is a table preferentially queried in the two tables used in the association operation; deduplicating values of the association field in the first query result set; and sending a result set delivery request and the deduplicated association field values to a shard database in which the non-driving table is located, so that the shard database in which the non-driving table is located generates temporary table data, wherein the temporary table data comprises the deduplicated association field values; sending a non-driving table query request to the shard database in which the non-driving table is located, and receiving a second query result set returned by the shard database in which the non-driving table is located, wherein the second query result set is obtained by means of querying according to the non-driving table query request and the temporary table data by the shard database in which the non-driving table is located; associating the first query result set with the second result set according to the association field, to obtain a third query result set; and returning the third query result set.