如何在自连接的单表中选择不匹配的记录

时间:2018-07-04 07:08:21

标签: sql oracle select

public class AdapterVarianti extends RecyclerView.Adapter<AdapterVarianti.ExampleViewHolder>  implements Filterable {


    private ArrayList<VariantiConstructor> variantiConstructors;
    private ArrayList<VariantiConstructor> mFilteredList;
    private OnItemClickListener mListener;

    public interface  OnItemClickListener{
        void onItemClick(int position);
    }

    public void setOnItemClickListener(OnItemClickListener listener){
        mListener = listener;
    }

    @NonNull
    @Override
    public AdapterVarianti.ExampleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.varianti_recycler,parent,false);
        RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        v.setLayoutParams(lp);
        return new AdapterVarianti.ExampleViewHolder(v, mListener);
    }

    AdapterVarianti(ArrayList<VariantiConstructor> exampleList){
        variantiConstructors = exampleList;
        mFilteredList = variantiConstructors;
    }

    @Override
    public void onBindViewHolder(@NonNull final AdapterVarianti.ExampleViewHolder holder, final int position) {
        final VariantiConstructor item = variantiConstructors.get(position);

        holder.desc.setText(item.getDeskT());
        holder.prepiu.setText(String.valueOf(item.getPrice()));
        holder.premeno.setText(String.valueOf(item.getPacq()));

        if(position % 2 == 0 ){
            holder.itemView.setBackgroundColor(Color.parseColor("#17e1a0"));

        }else if(position % 2 == 1){
            holder.itemView.setBackgroundColor(Color.parseColor("#7EC0EE"));
        }

    }


    @Override
    public Filter getFilter() {
        return new Filter() {
            @Override
            protected FilterResults performFiltering(CharSequence constraint) {
                final FilterResults oReturn = new FilterResults();
                final ArrayList<VariantiConstructor> results = new ArrayList<>();
                if (mFilteredList == null)
                    mFilteredList = new ArrayList<>(variantiConstructors);
                if (constraint != null && constraint.length() > 0) {
                    if (mFilteredList != null && mFilteredList.size() > 0) {
                        for (final VariantiConstructor cd : mFilteredList) {
                            if (cd.getDeskT().toLowerCase()
                                    .contains(constraint.toString().toLowerCase()))
                                results.add(cd);
                        }
                    }
                    oReturn.values = results;
                    oReturn.count = results.size(); //newly Aded by ZA
                } else {
                    oReturn.values = mFilteredList;
                    oReturn.count = mFilteredList.size(); //newly added by ZA
                }
                return oReturn;
            }

            @SuppressWarnings("unchecked")
            @Override
            protected void publishResults(final CharSequence constraint,
                                          FilterResults results) {
                variantiConstructors = new ArrayList<>((ArrayList<VariantiConstructor>) results.values);
                // FIXME: 8/16/2017 implement Comparable with sort below
                ///Collections.sort(itemList);
                notifyDataSetChanged();
            }
        };
    }

    @Override
    public int getItemCount() {
        return variantiConstructors.size();
    }

    public class ExampleViewHolder extends RecyclerView.ViewHolder {

        public TextView desc;
        public TextView prepiu;
        public TextView premeno;

        ExampleViewHolder(View itemView, final OnItemClickListener listener) {
            super(itemView);

            desc = itemView.findViewById(R.id.Desc);
            prepiu = itemView.findViewById(R.id.PrePiu);
            premeno = itemView.findViewById(R.id.PreMeno);


            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if(listener != null){
                        int position = getAdapterPosition();
                        if(position != RecyclerView.NO_POSITION){
                            listener.onItemClick(position);
                            Snackbar.make(v,variantiConstructors.get(position).getDeskT(),Snackbar.LENGTH_SHORT).show();
                        }
                    }
                }
            });


        }
    }


}

选择员工姓名和经理姓名,选择没有经理的人

1 个答案:

答案 0 :(得分:2)

如果没有加入,执行此操作可能会容易得多-只需检查管理员ID:

SELECT *
FROM   employees
WHERE  manager_id IS NULL