A few queries regarding a database query:
So, I have the following database query that contains a WHERE statement that includes three string variables (rackingSystem, manufacturer, Amber Risk).
public Cursor fetchComponentsAndSpecForManufacturer(long inspectionId, String rackingSystem, String manufacturer) { Cursor mCursor = rmDb.query(true, DAMAGED_COMPONENTS_TABLE, new String[] { DAMAGED_COMPONENT_ID, LOCATION_LINK, RUN_LINK, AREA_LINK, INSPECTION_LINK, LOCATION_REF, RACKING_SYSTEM, COMPONENT, COMPONENT_TYPE, QUANTITY, POSITION, RISK, ACTION_REQUIRED, NOTES_GENERAL, MANUFACTURER, TEXT1, TEXT2, TEXT3, TEXT4, NOTES_SPEC, SPEC_SAVED}, INSPECTION_LINK + " = " + inspectionId + " AND " + RACKING_SYSTEM + " = ? AND " + MANUFACTURER + " = ? AND " + RISK + " = ? ", new String[] {rackingSystem, manufacturer, "Amber Risk"}, COMPONENT_TYPE + ", " + TEXT1 + ", " + TEXT2 + ", " + TEXT3 + ", " + TEXT4 + ", " + NOTES_SPEC, null, null, null); if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; }
Question 1:
How to search for NULL as, in the above example, the manufacturer may be NULL in the database (since the user may not have added anything to the database for this bit yet).
Question 2:
Can I include an OR statement in a WHERE statement? Therefore, at the moment I am surfing for all records that are “Amber Risk”, but I also need to include “Red Risk” records in this list. If I can do this, how can I change the WHERE statement?