Facebook Developers
DocumentationSupportBlogAppsLog In
  • Getting Started
  • Core Concepts
  • Advanced Topics
    • Dialogs
    • FQL
    • Internationalization
    • Ads API
    • Credits
    • Chat API
    • Legacy REST API
    • Legacy FBML
    • Legacy FBJS
    • Legacy Javascript SDK
  • SDK Reference
  • Tools
  • Administrative Methods
    • admin.banUsers
    • admin.getAllocation
    • admin.getAppProperties
    • admin.getBannedUsers
    • admin.getRestrictionInfo
    • admin.setAppProperties
    • admin.setRestrictionInfo
    • admin.unbanUsers
    • application.getPublicInfo
    • batch.run
    • data.setCookie
    • fbml.setRefHandle
    • intl.getTranslations
    • intl.uploadNativeStrings
    • links.getStats
    • migrations.getStatuses
    • migrations.setStatus
    • pages.blockFan
  • Login/Auth Methods
    • auth.createToken
    • auth.expireSession
    • auth.getSession
    • auth.promoteSession
    • auth.revokeAuthorization
    • auth.revokeExtendedPermission
  • Data Retrieval Methods
    • comments.get
    • data.getCookies
    • fbml.refreshImgSrc
    • fbml.refreshRefUrl
    • fql.multiquery
    • fql.query
    • friends.areFriends
    • friends.get
    • friends.getAppUsers
    • friends.getLists
    • friends.getMutualFriends
    • groups.get
    • groups.getMembers
    • links.get
    • message.getThreadsInFolder
    • notes.get
    • notifications.get
    • notifications.getList
    • pages.getinfo
    • pages.isAdmin
    • pages.isAppAdded
    • pages.isFan
    • photos.get
    • photos.getAlbums
    • photos.getTags
    • privacy.get
    • profile.getFBML
    • profile.getInfo
    • profile.getInfoOptions
    • status.get
    • stream.get
    • stream.getComments
    • stream.getFilters
    • users.getInfo
    • users.getLoggedInUser
    • users.getStandardinfo
    • users.hasAppPermission
    • users.isAppUser
    • users.isVerified
    • video.getUploadLimits
  • Publishing Methods
    • comments.add
    • comments.remove
    • links.post
    • links.preview
    • liveMessage.send
    • notes.create
    • notes.delete
    • notes.edit
    • notifications.markRead
    • notifications.sendEmail
    • photos.addTag
    • photos.createAlbum
    • photos.upload
    • profile.setFBML
    • profile.setInfo
    • profile.setInfoOptions
    • status.set
    • stream.addComment
    • stream.addLike
    • stream.publish
    • stream.remove
    • stream.removeComment
    • stream.removeLike
    • users.setStatus
    • video.upload
  • Facebook Connect Methods
    • Mobile Methods
      • sms.canSend
      • sms.send
    • Dashboard API Methods
      • dashboard.decrementCount
      • dashboard.getCount
      • dashboard.incrementCount
      • dashboard.multiGetCount
      • dashboard.multiIncrementCount
      • dashboard.multiSetCount
      • dashboard.setCount
    • Events API Methods
      • events.cancel
      • events.create
      • events.edit
      • events.get
      • events.getMembers
      • events.invite
      • events.rsvp
    • Custom Tags API Methods
      • fbml.deleteCustomTags
      • fbml.getCustomTags
      • fbml.registerCustomTags
    • Ads Methods

      fql.multiquery

      Advanced Topics › Legacy REST API › fql.multiquery

      Evaluates a series of FQL (Facebook Query Language) queries in one call and returns the data at one time.

      This method takes a JSON-encoded dictionary called ''queries'' where the individual queries use the exact same syntax as a query made with fql.query. However, this method allows for more complex queries to be made. You can fetch data from one query and use it in another query within the same call. The WHERE clause is optional in the latter query, since it references data that’s already been fetched. To reference the results of one query in another query within the same call, specify its name in the FROM clause, preceded by #.

      For example, say you want to get some data about a user attending an event. Normally, you’d have to perform two queries in a row, waiting for the results of the first query before running the second query, since the second query depends on data from the first one. But with fql.multiquery, you can run them at the same time, and get all the results you need, giving you better performance than running a series of fql.query calls. First, you need to get the user ID and RSVP status of each attendee, so you’d formulate the first query – query1 – like this:

      "query1":"SELECT uid, rsvp_status FROM event_member WHERE eid=12345678"
      

      Then to get each attendee’s profile data (name, URL, and picture in this instance), you’d make a second query – query2 – which references the results from query1. You formulate query2 like this:

      "query2":"SELECT name, url, pic FROM profile WHERE id IN (SELECT uid FROM #query1)"
      

      This method also has better performance than running a series of fql.query calls with batch.run.

      Parameters

      NameTypeDescription
      queriesarray

      A JSON-encoded dictionary of the queries to perform. Each key is a query name, which can contain only alphanumeric characters and optional underscores. Each key maps to a value containing a traditional FQL query.

      callbackstring

      Name of a function to call. This is primarily to enable cross-domain JavaScript requests using the <script> tag, also known as JSONP, and works with both the XML and JSON formats. The function will be called with the response passed as the parameter.

      Warning: If you use JSON as the output format, you may run into problems when selecting multiple fields with the same name or with selecting multiple "anonymous" fields (for example, SELECT 1+2, 3+4 ...).

      Response

      This call returns a dictionary containing a list of query results in either JSON or XML format. The keys returned are the names of the queries made.

      As with fql.query, the data returned from each query very closely resembles the returns of other API calls like users.getInfo, as many API functions are simply wrappers for FQL queries.

      Updated about 8 months ago
      Facebook © 2012 · English (US)
      AboutCareersPlatform PoliciesPrivacy Policy