title: Query Two data in Database using Query
body: <p>I have a project that I want query two data in the firebase realtime database. The thing is , I am only getting one result in query that I want to make.
  Like SQL for example </p>
  
  <pre><code>SELECT * JOBS WHERE PHONE EQUAL TO PHONE 
  </code></pre>
  
  <p>I already understood that. And all I want is to combine where query the phone and query the date. I'm trying this, but the apps crash. Sorry for my bad English. I hope you guys understand what I mean.</p>
  
  <pre><code>public class CheckOrder extends AppCompatActivity {
  
  private static final String TAG = "Image";
  public RecyclerView recyclerView;
  public RecyclerView.LayoutManager layoutManager;
  
  FirebaseRecyclerAdapter&lt;BothJobs, JobViewHolder&gt; adapter;
  FirebaseRecyclerAdapter&lt;BothJobs, JobViewHolder&gt; checkadapter;
  
  private FirebaseDatabase database;
  private DatabaseReference jobs;
  
  
  MaterialSpinner spinner;
  
  String phone;
  String flightDate;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_check_order);
  
  
      database = FirebaseDatabase.getInstance();
      jobs = database.getReference("Jobs");
  
  
      recyclerView = findViewById(R.id.listCheckOrders);
      recyclerView.setHasFixedSize(true);
      layoutManager = new LinearLayoutManager(this);
      recyclerView.setLayoutManager(layoutManager);
  
      phone = Common.currentUser.getPhone();
      flightDate = Common.currentUser.getFlightDate();
  
      if (flightDate != null)
          loadOrders();
  
  
  }
  
  private void loadOrders() {
  
      final Query jobsProject = jobs.orderByChild("phone").equalTo(phone);
  
      jobsProject.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
  
              for (DataSnapshot movieSnapshot : dataSnapshot.getChildren()) {
                  BothJobs jobsCarrier = dataSnapshot.getValue(BothJobs.class);
  
                  if (jobsCarrier.getTimestamp().equals(flightDate)) {
  
                      adapter = new FirebaseRecyclerAdapter&lt;BothJobs, JobViewHolder&gt;(
                              BothJobs.class,
                              R.layout.check_order_layout,
                              JobViewHolder.class,
                              jobsProject
                      ) {
                          @Override
                          protected void populateViewHolder(JobViewHolder viewHolder, final BothJobs model, int position) {
  
                              viewHolder.tvId.setText("ID : " + adapter.getRef(position).getKey());
                              viewHolder.tvName.setText("Carrier Name : " + model.getName());
                              viewHolder.tvStatus.setText("Status : " + Common.convertCodeToStatus(model.getStatus()));
                              viewHolder.tvAirport.setText("Airport : " + model.getAirport());
                              viewHolder.tvAirlines.setText("Airlines : " + model.getAirlines());
                              viewHolder.tvLuggage.setText("Free Space Luggage : " + model.getSpace());
                              viewHolder.tvLocation.setText("Location Want To Go : " + model.getLocation());
                              viewHolder.tvPhone.setText("Carrier Contact : " + model.getPhone());
  
  
                              RequestOptions placeholderRequest = new RequestOptions();
                              placeholderRequest.placeholder(R.drawable.profile);
                              Glide.with(getBaseContext()).setDefaultRequestOptions(placeholderRequest).load(model.getImage()).into(viewHolder.imageCarrier);
  
                              RequestOptions placeholderRequest2 = new RequestOptions();
                              placeholderRequest2.placeholder(R.drawable.wedee);
                              Glide.with(getBaseContext()).setDefaultRequestOptions(placeholderRequest2).load(model.getFlightDetail()).into(viewHolder.flightDetail);
  
                              viewHolder.btn_checkJob.setOnClickListener(new View.OnClickListener() {
                                  @Override
                                  public void onClick(View v) {
  
                                      //Intent to ChooseJob
  
                                      Toast.makeText(CheckOrder.this, "Job" + model.getId(), Toast.LENGTH_SHORT).show();
  
                                  }
                              });
  
  
                          }
                      };
                      adapter.notifyDataSetChanged();
                      recyclerView.setAdapter(adapter);
  
  
  
  
                  }
              }
  
  
          }
  
          @Override
          public void onCancelled(@NonNull DatabaseError databaseError) {
  
          }
      });
  
  
  
  
  
  
  }
  
  
  }
  </code></pre>
  
  <p>I'm trying to match the also the timestamp equal flight date with phone equal to phone. But nothing appearing, i didn't get any crash for now.
  <a href="https://i.stack.imgur.com/b9oVt.png" rel="nofollow noreferrer">this image from "Jobs" ref</a>
  <a href="https://i.stack.imgur.com/bzG9e.jpg" rel="nofollow noreferrer">this image from "User" ref</a></p>